This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC 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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "invalid cursor state" Watch "invalid cursor state" New topic
Author

invalid cursor state

Balaji kkk
Greenhorn

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..


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


<a href="http://www.newlatesttechnology.blogspot.com" target="_blank" rel="nofollow">more DownLoad here..</a>
Kalyan Anand
Ranch Hand

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

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
cheers!!
Srikanth Basa
Ranch Hand

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

Joined: Jun 06, 2007
Posts: 2716
    
    6

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.


SCJP, SCWCD.
|Asking Good Questions|
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: invalid cursor state
 
Similar Threads
jsp and jdbc
dispatching to servlets and JSPs
Invalid Cursor State!!
Connection Pooling Problem
sending email using javamail api