• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

invalid cursor state

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
from which line ?
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!
 
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use this
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic