Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

before start use result set error

 
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
 
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
 
Something must be done about this. Let's start by reading this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic