This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Problem Creating a Prepared Statement 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 "Problem Creating a Prepared Statement" Watch "Problem Creating a Prepared Statement" New topic
Author

Problem Creating a Prepared Statement

Michael Craghead
Greenhorn

Joined: Mar 12, 2006
Posts: 12
I'm trying to create a prepared statement that uses '?' for substitution. The problem that I'm having is that I get an error during execution indicating that there is an invalid "?" in my Update statement. It's right when I try to create the prepared statement:

com.ibm.db2.jcc.b.SqlException: Invalid cursor name "?" in the Update/Delete statement.
at com.ibm.db2.jcc.b.tf.b(tf.java:312)
at com.ibm.db2.jcc.b.tf.<init>(tf.java:259)
at com.ibm.db2.jcc.c.dc.<init>(dc.java:93)
at com.ibm.db2.jcc.c.b.b(b.java:1840)
at com.ibm.db2.jcc.b.p.a(p.java:2124)
at com.ibm.db2.jcc.b.p.prepareStatement(p.java:1017)
at com.mytest.commit.Commit.main(Commit.java:41)

Is cursor name substitution not valid in a preparded statement, or maybe in a DB2 prepared statement? I'm guessing that maybe something that I'm overlooking in my update string that is causing the problem, but I just can't figure out what it might be. It doesn't seem to complain about the other '?' in the update string.

This is what I have:


Thanks for the help.


Michael K. Craghead<br />�Timba or muerte!
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2278
    
  28

I don't think you can pass cursor name as a parameter to a PreparedStatement. Why are you doing it this way as oppossed to

Michael Craghead
Greenhorn

Joined: Mar 12, 2006
Posts: 12
Jayesh A Lalwani wrote:I don't think you can pass cursor name as a parameter to a PreparedStatement. Why are you doing it this way as oppossed to



I cut out the actual processing details from what I'm trying to do to eliminate clutter. I don't want to set itim_updated until I've done my processing. I'm iterating through my result set, doing some processing based on the current record, then updating itim_updated (record has been processed). I don't want to update all of the records with recertstatus = 'S' and itim_updated = 'N', as some records might not be processed successfully. Think of it as each row in my result set as a transaction. I hope this is clear.

Thanks.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem Creating a Prepared Statement
 
Similar Threads
Help: HTTP method GET error
iSeries V5R2-Native DB2 access in QShell-ClassNotFoundException
InvalidAlgorithmParameterException
Error when getting a connection from DB2 DB
problem regarding DatabaseMetaData.....