Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Operation not allowed after ResultSet closed.

 
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an application that I'm migrating from MySQL ver 4 to ver 5. I had to update the connector jar in order to get it to work. However, now I'm running into some unusual behavior. This code worked perfectly fine with ver 4, but breaks with ver 5 and the updated connector.

Basically, this is the pattern the program uses when talking to the database.

1. Open connection
2. Run SQL statement
3. Close connection
4. Do stuff with result set

MySQL ver 5 is complaining about this and saying that you can't do anything with the result set after you've closed the connection. Is there a reason this changed between versions?

Also, is there a recommended method of dealing with the data? The currrent setup passes around the result set and performs operations on it.

And unfortunately, rewriting everything to use Hibernate isn't an option. Perhaps later, but right now I just need to get the existing functionality working with the newer version of MySQL.

TIA.
 
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi. From the java.sql.ResultSet documentation:
"(...)A ResultSet object is automatically closed when the Statement object that generated it is closed, re-executed, or used to retrieve the next result from a sequence of multiple results.(...)"

And from a random getXXX method defined by ResultSet:
"(...)Throws:
SQLException - if the columnIndex is not valid; if a database access error occurs or this method is called on a closed result set (...)"

So, whatever you were doing, was against the specification of JDBC. Maybe the connector was implemented in the wrong way - for example, old MySQL connectors version 2.xx had this problem. The only thing to do to be in synch with the specs is to change the code, I'm affraid
 
Bai Shen
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I figured as much. I just wanted a second opinion.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic