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 invalid cursor state 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 "invalid cursor state" Watch "invalid cursor state" New topic

invalid cursor state

Balaji kkk

Joined: Oct 05, 2008
Posts: 3
i am using netbean for connecting jdbc but i getting invalid cursor state i using below given code ,any one can retify this error..

}catch(Exception e){
out.println("Nt able to find class"+e.getMessage());
Connection conn=DriverManager.getConnection(URL,"scott","tiger");
Statement stmt=conn.createStatement();

ResultSet com=stmt.executeQuery("select username from table1 where act=1");
String use=com.getString("username");

int i=stmt.executeUpdate("INSERT INTO"+use+" VALUES(toaddress='"+sto+"',subject='"+ssubject+"',body='"+body+"',place ='sentitems')");
//int j=stmt.executeUpdate("INSERT INTO"+sto+" VALUES(toaddress='"+user+"',subject='"+ssubject+"',body='"+body+"',place ='inbox')");
catch(Exception e)
out.println("not able to update"+e.getMessage());
} :p

<a href="" target="_blank" rel="nofollow">more DownLoad here..</a>
Kalyan Anand
Ranch Hand

Joined: Feb 07, 2007
Posts: 194
from which line ?
chintan shah

Joined: Oct 05, 2008
Posts: 7
when you get the result data into your ResultSet, the cursor is placed before the first row...hence you need to use the next method on the resultset object to place the cursor on the correct position and then try extracting data from it
Srikanth Basa
Ranch Hand

Joined: Jun 06, 2005
Posts: 241
Use this
Amit Ghorpade

Joined: Jun 06, 2007
Posts: 2851

Hi Balaji kkk welcome to Javaranch ,

Firstly it looks like your display name does not follow the Javaranch naming policy . Please change it using the My Profile link above.
Then add code tags to your code. Unformatted code is hard to read and will bring down the number of responses you get.

|Asking Good Questions|
I agree. Here's the link:
subject: invalid cursor state
It's not a secret anymore!