This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases 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 and Relational Databases
Bookmark "before start use result set error" Watch "before start use result set error" New topic

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 );

i kindly need the sollution for the above.

Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
You need to call 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 to make sure there is a record in the ResultSet.


Java API Documentation
The Java Tutorial
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: before start use result set error
It's not a secret anymore!