Article View: aus.computers.java
Article #1096Re: help - resultset
From: 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;
Technical Details
Message-ID:
<7mi20i$42n$1@the-fly.zip.com.au>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<378c5de5@dvs1.aus.to>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d6db,95c997fcc95fe86c X-Google-Attributes: gid10d6db,public From: nospam@no.spam.thanks (James Cribb) Subject: Re: help - resultset Date: 1999/07/14 Message-ID: <7mi20i$42n$1@the-fly.zip.com.au> X-Deja-AN: 500911589 References: <378c5de5@dvs1.aus.to> Organization: Zip World Reply-To: jamesc@zip.com.au Newsgroups: aus.computers.java