my dog learned polymorphism
The moose likes JDBC and Relational Databases and the fly likes PreparedStatement  issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Reply locked New topic

PreparedStatement issue

Manu Ramakrishnan

Joined: Jun 07, 2003
Posts: 10
Hi guys,
I think the question in my previous post was not clear enough.
Please go through the code snippet.
PreparedStatement ps = con.prepareStatement("UPDATE GIFI SET DESCRIPTION=?,TYPE=? WHERE ACCNO=?");
ps.setString(2, "CHEQUE");
ps.setString(3, "1000");
For some updations,I have to skip the first parameter, because I will not have genuine value for this field. In that scenario, I don't want the existing value in the database field to be disturbed. I want to retain the value.
How will I go about this by using prepared statements instead of building the queries dynamically using simple statements?. we are more inclined towards prepared statements b'cos we have a huge amounts of data inserted/updated.
Billybob Marshall
Ranch Hand

Joined: Jan 27, 2004
Posts: 202
This is just as bad as cross-posting. See original thread
The answers provided should suffice. Restated though, if you want to retain the original field value, then a set for it shouldn't be included in your statement.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63838

Billy is correct. Please continue the discussion in the original topic.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: PreparedStatement issue
It's not a secret anymore!