File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Update Using a preparedstatement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Update Using a preparedstatement" Watch "Update Using a preparedstatement" New topic

Update Using a preparedstatement

Ransika deSilva
Ranch Hand

Joined: Feb 18, 2003
Posts: 524
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=?");
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.

SCJP 1.4, SCMAD 1.0<br />SCWCD, SCBCD (in progress)
Chantal Ackermann
Ranch Hand

Joined: Sep 28, 2000
Posts: 508
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?
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

Yep... moving this to the JDBC forum...

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

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.
I agree. Here's the link:
subject: Update Using a preparedstatement
It's not a secret anymore!