• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Resultsets survives failure

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having java code the snippets of which are

Connection con = DriverManager.getConnection("-------");
Statement stmt = con.createStatement("----");
ResultSet rs = stmt.executeQuerty("Select * from Emp");

After executing this statement if the oracle database server crashes,I still want to maintain my resultset.Would the object "rs" still pursive or not?
 
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nope, that resultset is dependent on the connection object being valid. If the server crashes, the connection object is hosed. The next time you try to use it, you will probably receive an SQLException that's wrapped around an IOException.

For that and other reasons, it is often a good idea to immediately read your ResultSet and store it into a disconnected data structure. For example, a simple way to do that is to iterate through the ResultSet and store each record into an Onject[] array and put each array into an ArrayList. Once you have your ArrayList built, you no longer need the ResultSet and you can close it.

Of course, if the db server crashes while you are still iterating the ResultSet, your out of luck.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic