aspose file tools*
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
JavaRanch » Java Forums » Databases » JDBC
Bookmark "invalid cursor state" Watch "invalid cursor state" New topic
Author

invalid cursor state

kelly devon
Ranch Hand

Joined: Apr 15, 2004
Posts: 75
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 ]

kel
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
kelly devon
Ranch Hand

Joined: Apr 15, 2004
Posts: 75
ok im sorry about that
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

No problem.
Oricio Ocle
Ranch Hand

Joined: Nov 30, 2004
Posts: 284

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


SCJP, OCMJD, OCMJEA
uday tiruveedula
Greenhorn

Joined: Dec 11, 2004
Posts: 2
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'
Rajendar Goud
Ranch Hand

Joined: Mar 06, 2002
Posts: 220
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

Joined: Mar 06, 2002
Posts: 220
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

Joined: Apr 15, 2004
Posts: 75
thx alot guys all ur contributions helped alot i appreciate ths
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: invalid cursor state