File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes before start use result set error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "before start use result set error" Watch "before start use result set error" New topic
Author

before start use result set error

riyaz udeen
Ranch Hand

Joined: Sep 11, 2005
Posts: 66
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

Joined: Dec 06, 2001
Posts: 3061
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


Java API Documentation
The Java Tutorial
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: before start use result set error
 
Similar Threads
Syntax error
sql query error
Problem with servlet reading images in database!
Using Rownum in JDBC
incrementing numbers in database when a new object is added