This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

invalid cursor state

 
kelly devon
Ranch Hand
Posts: 78
  • 0
  • Mark post as helpful
  • send pies
  • 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 ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok im sorry about that
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No problem.
 
Oricio Ocle
Ranch Hand
Posts: 284
Debian Firefox Browser Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
uday tiruveedula
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • 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'
 
Rajendar Goud
Ranch Hand
Posts: 220
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thx alot guys all ur contributions helped alot i appreciate ths
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic