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

Can we use PrepareStatement for deleting?

 
Gaurav Chikara
Ranch Hand
Posts: 412
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Raja Shekhar
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gaurav..
The Syntax is wrong...
here
pstmt.setString(value_from_jsp);
change it to
pstmt.setString(1,value_from_jsp);
bye
Raj
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic