This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is any problem with this code?

 
Jayii Young
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Statement sql = con.createStatement();
ResultSet rs1 = sql.executeQuery(sql1);
ResultSet rs2 = sql.executeQuery(sql2);
String Value1 = rs1.getString(1);
String Value2 = rs2.getString(1);
 
Blake Minghelli
Ranch Hand
Posts: 331
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jayii Young:
Statement sql = con.createStatement();
ResultSet rs1 = sql.executeQuery(sql1);
ResultSet rs2 = sql.executeQuery(sql2);
String Value1 = rs1.getString(1);
String Value2 = rs2.getString(1);

Yes, that won't work correctly. A Statement can only be used to read one ResultSet at a time. As soon as you execute the second query, the first ResultSet is automatically closed.
If you need to read from more than one ResultSet at a time, then you must use different Statements.
 
Jayii Young
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Blake!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic