aspose file tools*
The moose likes JDBC 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
Reply locked New topic
Author

PreparedStatement issue

Manu Ramakrishnan
Greenhorn

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.
con=ConnectionManager.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE GIFI SET DESCRIPTION=?,TYPE=? WHERE ACCNO=?");
ps.setString(2, "CHEQUE");
ps.setString(3, "1000");
System.out.println(ps.execute());
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.
Thanks
Manu
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
Marshal

Joined: Jan 10, 2002
Posts: 61221
    
  66

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: PreparedStatement issue