Thread View: aus.computers.java
4 messages
4 total messages
Started by Prescott Pym
Wed, 14 Jul 1999 00:00
help - resultset
Author: Prescott Pym
Date: Wed, 14 Jul 1999 00:00
Date: Wed, 14 Jul 1999 00:00
26 lines
1419 bytes
1419 bytes
hello
I'm having a bit of trouble..I have a resultset that I wish to return to
another function, but it is created within a try { } block, thus the return
statement cannot return it...here is the code
ResultSet callDatabase ()
{
ResultSet rs;
try
{
String url = "jdbc:odbc:HighVoltage";
String query = "SELECT * FROM CURRENCIES";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection(url,"","");
Statement stmt = con.createStatement();
rs = stmt.executeQuery(query);
}
......
return rs;
}
how can I get around this (I'm just a beginner to database coding).
thanks
Prescott
Re: help - resultset
Author: James Cribb
Date: Wed, 14 Jul 1999 00:00
Date: Wed, 14 Jul 1999 00:00
26 lines
1281 bytes
1281 bytes
In article <378c5de5@dvs1.aus.to>, Prescott Pym wrote:
|
| I'm having a bit of trouble..I have a resultset that I wish to return to
| another function, but it is created within a try { } block, thus the return
| statement cannot return it...here is the code
|
| ResultSet callDatabase ()
| {
| ResultSet rs;
| try
| {
| String url = "jdbc:odbc:HighVoltage";
| String query = "SELECT * FROM CURRENCIES";
| Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
| Connection con = DriverManager.getConnection(url,"","");
| Statement stmt = con.createStatement();
| rs = stmt.executeQuery(query);
| }
| ......
| return rs;
| }
Looks ok to me. If your compiler warns that rs may not be initialised,
try initialising it explicitly to null when you declare it:
ResultSet rs = null;
Re: help - resultset
Author: Tom Davies
Date: Fri, 16 Jul 1999 00:00
Date: Fri, 16 Jul 1999 00:00
3 lines
740 bytes
740 bytes
What error do you get? Tom
Re: help - resultset
Author: Dion Gillard
Date: Fri, 16 Jul 1999 00:00
Date: Fri, 16 Jul 1999 00:00
35 lines
1577 bytes
1577 bytes
In article <378c5de5@dvs1.aus.to>, ppym@bigpond.net.au says...
| hello
|
| I'm having a bit of trouble..I have a resultset that I wish to return to
| another function, but it is created within a try { } block, thus the return
| statement cannot return it...here is the code
|
| ResultSet callDatabase ()
| {
| ResultSet rs;
| try
| {
| String url = "jdbc:odbc:HighVoltage";
| String query = "SELECT * FROM CURRENCIES";
| Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
| Connection con = DriverManager.getConnection(url,"","");
| Statement stmt = con.createStatement();
| rs = stmt.executeQuery(query);
| }
| ......
| return rs;
| }
|
| how can I get around this (I'm just a beginner to database coding).
This doesn't have anything to do with db coding....all local variables
(to a method) must be given a value.
Replace:
| ResultSet rs;
with:
| ResultSet rs = null;
--
dIon
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads