This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
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: 2846

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|
Don't get me started about those stupid light bulbs.
subject: invalid cursor state
jQuery in Action, 3rd edition