This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hello - I am having problems setting values for my prepared statement (below).
psViewLogIncrement = conn.prepareStatement( SELECT TOP ? * FROM Log WHERE (record_id >=(SELECT MAX(record_id)FROM (SELECT TOP ? * FROM Log ORDER BY record_id) nextRecords)) ORDER BY record_id ); psViewLogIncrement.setInt(1, 2); psViewLogIncrement.setInt(2, 2);
The values I would like to set are not data field values, but the number of values I would like the Select to return. The error I'm getting is: "java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Invalid parameter binding(s)."
Hi Gale, Unfortunately, you cannot put a place holder (i.e. question-mark ["?"]) anywhere you want to, in a "PreparedStatement" -- and that is what you are trying to do -- hence the "Invalid parameter bindings" error message you are receiving. You could do something like this: [Note: Only a suggestion]
Good Luck, Avi.
Joined: Aug 05, 2002
Ahh ha! I actually did what you had suggested and used a "Statement" instead of a "PreparedStatement". Thanks so much for your reply - much appriciated!
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Prepared Statement - only for field values?