Win a copy of Spring Boot in Practice this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

invalid cursor state

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
im retrievin values from my db, and at the same time up
dating my db, with new values from the gui after verification.
i am not using rs.next() because the pointer is going straight
to get the info with respet to the idno. After sending the
message i get an invalid cursor state,and the values am supposed
to retrieve
are empty and i have records in my db pls what am i doing wrong?

thx for help
heres the code

[ December 09, 2004: Message edited by: kelly devon ]
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'll have to post your code. And can you use punctuation and capitalisation in your posts please. Its kind of difficult to read your post, and you are cutting down the likelyhood of the non-native English speakers who read this site being able to help you.
 
kelly devon
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok im sorry about that
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No problem.
 
Ranch Hand
Posts: 284
Netbeans IDE Firefox Browser Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello kelly,
which JDBC driver are you using?
If the driver supports precompilation, i should use PreparedStatement objects since this queries/updates seem to be a common task in your program.
Regards
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i think the problem is with the query string being passed for the update statement. please check the spaces as u haven't given the space before 'WHERE' and after 'LIKE'
 
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
kelly,
your code,
try
{
qtytotal = qtytxt.getText();
identity = identxt.getText();
rs= salesmade.executeQuery("SELECT idno,qty FROM STOCK");
String quantity = rs.getString("qty");
String id = rs.getString("idno");
if(identity == idno)
salesmade.executeUpdate("UPDATE STOCK SET qty ="+'"+qtytotal+"'"+"WHERE idno LIKE" +"'+identity+'");
}catch(SQLException qex)
{
System.out.prinln(qex.toString());
}

Once you open the connection and query a database,
run the loop to check whether you have the results or not!


String quantity="";
String id = "";
try
{
qtytotal = qtytxt.getText();
identity = identxt.getText();
rs= salesmade.executeQuery("SELECT idno,qty FROM STOCK");

quantity = rs.getString("qty");
id = rs.getString("idno");
if(identity.equals(idno))
salesmade.executeUpdate("UPDATE STOCK SET qty ="+'"+qtytotal+"'"+"WHERE idno LIKE" +"'+identity+'");
}catch(SQLException qex)
{
System.out.prinln(qex.toString());
}
 
Rajendar Goud
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
kelly,
sorry,reply was incomplete!
try
{
qtytotal = qtytxt.getText();
identity = identxt.getText();
rs= salesmade.executeQuery("SELECT idno,qty FROM STOCK");
String quantity = rs.getString("qty");
String id = rs.getString("idno");
if(identity == idno)
salesmade.executeUpdate("UPDATE STOCK SET qty ="+'"+qtytotal+"'"+"WHERE idno LIKE" +"'+identity+'");
}catch(SQLException qex)
{
System.out.prinln(qex.toString());
}

Once you open the connection and query a database,
run the loop to check whether you have the results or not!

String quantity="";
String id = "";
try
{
qtytotal = qtytxt.getText();
identity = identxt.getText();
rs= salesmade.executeQuery("SELECT idno,qty FROM STOCK");
while(rs.next()) {
quantity = rs.getString("qty");
id = rs.getString("idno");
}
if(identity.equals(id))
salesmade.executeUpdate("UPDATE STOCK SET qty ="+'"+qtytotal+"'"+" WHERE idno LIKE " +"'+identity+'");
}catch(SQLException qex)
{
System.out.prinln(qex.toString());
}


-Rajendar
 
kelly devon
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thx alot guys all ur contributions helped alot i appreciate ths
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic