Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Update Using a preparedstatement

 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,
i have this question. i want to update a data base record. so i am using this coding.
PreparedStatement st_stockaddps=st_stockaddcon.prepareStatement("INSERT INTO inventory VALUES("+st_descriptionst+","+st_ppust+","+st_qtyst+","+st_reorderlevelst+","+st_suppliercodest+","+st_totalcostst+","+st_totalcostst+")WHERE I_Code=?");
st_stockaddps.setString(1,st_itemcodest);
st_stockaddps.executeUpdate();
but the problem is when i execute this statement it gives a sql exception saying "Missing semicolon( at the end of sql statement..
please send a quick reply. thank you.
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
you certainly will have more success by posting this at the jdbc forum.
normally the jdbc driver cares for semicolons at the end. so at a first glance, this seems to be a driver problem?
cheers,
chantal
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep... moving this to the JDBC forum...
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your problem stems from the fact that you are performing an INSERT with a WHERE clause. You can not have a WHERE clause on an insert.
Jamie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic