Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQLException : Invalid cursor state

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
whenever i try to store the records in a resultset (i.e. give stmt.executeQuery("select * from table") from oracle i get this exception. but i can update and insert new / old records as the case. What should i do ? very desperate please help.
 
narayan kulkarni
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The invalid cursor state exception comes when you do not move your cursor to next record before executing the query
What I mean exactly is if you have created a ResultSet object as
ResultSet rs= new ResultSet();
just execute rs.next() method to move it to next record and you might be knowing that using cursors you can access only one row from the table at once
So you need to put this thing in a while loop like
while(rs.next()
{
//the code to read the data from database
}

I hope you got what I mean
let me know if it worked
Regards
narayan
------------------
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mr. Cube, when you registered here at JavaRanch you agrred to this:

For your user name, use a first name, a space and a last name.
No commas or underscores, and the last name must be more than one letter. Obviously fictitious names or improperly formatted names may be locked out.

So, unless you are friends with Dr. Dre and Gangsta Ru, we would appreciate you using a real name. Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic