• Post Reply Bookmark Topic Watch Topic
  • New Topic

Get value returned by query  RSS feed

 
Isaac Ferguson
Ranch Hand
Posts: 1063
3
Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have this code, and I want to set into a variable the result of a query.



Any idea, please?

Regards, Isaac
 
Dave Tolls
Ranch Foreman
Posts: 3068
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The execute method returns a ResultSet object.
You need to use the next() method on that (in a while loop if you expect multiple rows) and then you can read that data for that row.

Your second Statement is completely unnecessary.

Also, you need to make sure you close off your resources (ResultSet, PreparedStatement, Connection).
 
Isaac Ferguson
Ranch Hand
Posts: 1063
3
Java Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes thanks...I remember from old school days
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!