• 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

before start use result set error

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic