aspose file tools*
The moose likes JDBC and the fly likes java.sql.SQLException: After end of result set Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "java.sql.SQLException: After end of result set" Watch "java.sql.SQLException: After end of result set" New topic
Author

java.sql.SQLException: After end of result set

Fred Pepin
Greenhorn

Joined: Mar 08, 2003
Posts: 2
Hi all,
I'm having a problem and I'm about to go insane.
I use Apache/Tomcat/4.1.12 and Connector/J 3.0.6 to connect to a MySQL 3.23.55 Database server.
For some very obscur reason, I'm getting an error on every second query using the same connection.
The weird part is that the same query crash on the second time too
Here's my code:
Connection conn = null;
try{
double radius = 5.0;
String zip = "20211";
radius = radius/69.1;
double latRef = 0.0;
double longRef = 0.0;
double latRefmR = 0.0;
double latRefpR = 0.0;
double longRefmR = 0.0;
double longRefpR = 0.0;
conn = ConnectionGenerator.getConnection();
Statement stmt = conn.createStatement();
ResultSet result = stmt.executeQuery(" SELECT zip_codes, zip_latitude, zip_longitude FROM zip_codes WHERE zip_codes ='"+ zip +"'");

if( result.next() )
{
latRef = result.getDouble(2);
longRef = result.getDouble(3);
latRefmR = latRef - radius;
latRefpR = latRef + radius;
longRefmR = longRef - radius;
longRefpR = longRef + radius;
}
result.close();
result = null;
stmt.close();
stmt = null;
stmt = conn.createStatement();
result = stmt.executeQuery("
SELECT zip_codes, zip_latitude, zip_longitude FROM zip_codes WHERE zip_codes ='"+ zip +"'");

while( result.next() );
{
//It crash here
result.getDouble("zip_codes");

}
result.close();
stmt.close();
conn.close();
}
catch(Exception eee)
{
eee.printStackTrace();
conn.close();
}
Any help would be greatly appreciated,
Frederic
Fred Pepin
Greenhorn

Joined: Mar 08, 2003
Posts: 2
Thanks but I found the problem...
Frederic
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.sql.SQLException: After end of result set