This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes the JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "the JDBC "invalid state cursor" error" Watch "the JDBC "invalid state cursor" error" New topic
Author

the JDBC "invalid state cursor" error

Aman Agarwal
Greenhorn

Joined: Apr 04, 2010
Posts: 3
i am getting an error when executing this section of code
ResultSet rs=st.executeQuery("select * from crawl where enteredURL='"+inputurl+"'");
int a = rs.getInt("ID");

the error is invalid state cursor.
can anyone help me out to eliminate the error?
it will of immense help!!

PS: ID(type integer) is a field name in table "crawl" and enteredURL(type : text) is another field in the same table..these are the only fields in table "crawl"
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 32317
    
213

Aman,
You need to call rs.next() before rs.getInt().


[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 32317
    
213

Almost forgot - Welcome to JavaRanch!
Aman Agarwal
Greenhorn

Joined: Apr 04, 2010
Posts: 3
yeah thanks ...got the code rectified and it's working now...
thank you for your help!!!

[replace tnks by thank you, 4 by for, n by and]
 
Don't get me started about those stupid light bulbs.
 
subject: the JDBC "invalid state cursor" error
 
It's not a secret anymore!