Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using SEQUENCE In JDBC

170863Oct 14 2003 — edited Oct 15 2003

I'm using Oracle 8i with JDBC.

I use something like this in my Java application:

pStmt = con.prepareStatement("SELECT MY_ID.NEXTVAL FROM DUAL");
rs = pStmt.executeQuery();
rs.next();
int id = rs.getInt(1);

At this point of fetching the value from the ResultSet, I get this SQL error:
Invalid operation for the current cursor position

The ResultSet is must return one row, so the above code snippet is valid. Then, why do I get this error?

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 12 2003
Added on Oct 14 2003
7 comments
1,657 views