my dog learned polymorphism
The moose likes JDBC and Relational Databases 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 Groovy Fundamentals video training course this week in the Groovy forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can we use PrepareStatement for deleting?