i wonder if the following has ever happened to you: using mysql driver 3.XX my application works perfectly, but from the moment i change the mysql driver to version 5.XX i get a dreaded java.sql.sqlexception: operation not allowed after resultset closed error message
here's the code i'm using (against a mysql 5 database)
When the Statement is closed, the ResultSet is closed. The Statement is closed when it goes out of scope. The question is not really why does it work in v3 and not in v5. It should be how did it work in v3 at all? Are you asking how to change your code to avoid the error?
Well, not quite. The Statement object is probably being closed by a finalizer when it's garbage-collected. But Tom's point is still correct: the new version works differently because it fixed a bug which was caused by careless code which didn't close JDBC objects properly. So now that code throws an exception instead of leaving open connections to the database.
Joined: Feb 08, 2004
jdbc isnt my strongest point, so i dont understand quite well were the problem with my code might be
here's how i close the connection:
You close the connection before the resultset is returned, because the finally block executes before the executeQuery() method is exited.
(even though your return statement comes before the finally block, the finally is executed before you exit the method and return the set)à
And a resultset with a closed connection is a closed resultset;