aspose file tools*
The moose likes JDBC 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
Bookmark "Update Using a preparedstatement" Watch "Update Using a preparedstatement" New topic
Author

Update Using a preparedstatement

Ransika deSilva
Ranch Hand

Joined: Feb 18, 2003
Posts: 524
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.


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

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

Joined: Oct 18, 2000
Posts: 4121

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


-Nate
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.
Jamie
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Update Using a preparedstatement