This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC 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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30138
    
150

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


[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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30138
    
150

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]
 
 
subject: the JDBC "invalid state cursor" error
 
Similar Threads
Writing File(Excel) in ResultSet
Display error when record not found
Invalid cursor state?
connection problem
JDBC & SQL Error List Help