wood burning stoves 2.0*
The moose likes JDBC and the fly likes Can we use PrepareStatement for deleting? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Can we use PrepareStatement for deleting?" Watch "Can we use PrepareStatement for deleting?" New topic
Author

Can we use PrepareStatement for deleting?

Gaurav Chikara
Ranch Hand

Joined: Jun 09, 2000
Posts: 410
And I think answer to this question should be yes
but when I am using it and calling the update function from my jsp
it do not seem to work
As far as I think this syntax is correct
void update()
{
PreparedStatement pstmt = con.prepareStatement("delete from table where colname= ?");
pstmt.clearParameters();
pstmt.setString(value_from_jsp);
pstmt.executeUpdate();
con.commit();
}
Correct me anyone if I am wrong?

SCJP,SCWCD,SCBCD<br />If Opportunity doesn't knock then build the door
Raja Shekhar
Ranch Hand

Joined: Apr 02, 2001
Posts: 49
Hi Gaurav..
The Syntax is wrong...
here
pstmt.setString(value_from_jsp);
change it to
pstmt.setString(1,value_from_jsp);
bye
Raj
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Can we use PrepareStatement for deleting?
 
Similar Threads
How to update a database using web forms
Problem while Running JMeter Scripts for updating the record
paint
delete in B&S
get data from html tables and send it to controller/servlet