Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

invalid cursor state

 
Balaji kkk
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am using netbean for connecting jdbc but i getting invalid cursor state i using below given code ,any one can retify this error..


try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(Exception e){
out.println("Nt able to find class"+e.getMessage());
}
try{
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");

out.println("hai");
out.println(use);
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')");
//out.println(ssubject);
//response.sendRedirect("main.htm");
}
catch(Exception e)
{
out.println("not able to update"+e.getMessage());
}
} :p
 
Kalyan Anand
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
from which line ?
 
chintan shah
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
cheers!!
 
Srikanth Basa
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use this
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic