File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes why Invalide cursor state exception 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 "why Invalide cursor state exception " Watch "why Invalide cursor state exception " New topic

why Invalide cursor state exception

Arun Maalik
Ranch Hand

Joined: Oct 25, 2005
Posts: 216

Dear sir i have just created a table in oracle under the scott user whose name is User_Login when i am retriving data by above coding it is throwing an exception that Invalide cursor state why sir? But i am sure that my code is right.
Same coding when i am using with predifined table like emp in scott user by the same code it is working fine.

with regard

Arun kumar maalik
[ August 20, 2006: Message edited by: Barry Gaunt ]
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
this is not the correct place to ask JDBC questions.

but for a quick guess: are you sure there's a result being returned? If not, you can't read from the resultset because next() places it beyond the end of the results.

Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Moving to JDBC... (from SCJD)
[ August 20, 2006: Message edited by: Barry Gaunt ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Arun Maalik
Ranch Hand

Joined: Oct 25, 2005
Posts: 216
Sorry sir but i am sure that table is returning rows in ResultSet because when i am using ResultSetMetadata and using function like
getColumnCount it is returning how many column are retriving.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33102

Not neccessarily. The getColumns is telling you about the form of the resultset. JDBC considers the resultset to have the same columns as the SQL query, even if nothing is returned.

Try running your query at the SQL command line to see if it returns anything.

Also, try something like the following to make the code more robust against this case. It'll be a lot easier to find out why things failed.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: why Invalide cursor state exception
jQuery in Action, 3rd edition