This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

before start use result set error

 
riyaz udeen
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well everyone i apolozise for frequent post. but its worth.

when i used scrollable result set coding - i faced the error - before start
use result set(during runtime).here is the code in my programm :
=================================
public static void main ( String arg[]) {
try {
Connection c = DriverManager ......................
Statement st = c.createStatement( ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_UPDATABLE);
ResultSet r = st.executeQuery("SELECT * FROM riyaz WHERE name = 'fayaz' ");
r = st.executeQuery("SELECT * FROM riyaz WHERE name = 'fayaz' ");
Integer marks = r.getInt("marks");
r.updateInt("marks", 20 +marks );
r.updateRow();

====================================
i kindly need the sollution for the above.

riyaz
scjp1.4
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to call r.next() before you call r.getXxx() methods. This makes the ResultSet point to the first record. If you don't do this, the ResultSet is pointing BEFORE the first record. Also be sure to check the return value of r.next() to make sure there is a record in the ResultSet.

Layne
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic