File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Error Setting parameters in a Update preparedstatments Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Error Setting parameters in a Update preparedstatments" Watch "Error Setting parameters in a Update preparedstatments" New topic
Author

Error Setting parameters in a Update preparedstatments

Tom Schindler
Greenhorn

Joined: Jul 15, 2009
Posts: 8
Hey guys I have been working on making a form that updates a Microsoft Access database and I cannot seem to figure out the root of this error I continue to receive.

My edit form upon loading displays the information for a selected item. There is a submit button that updates the database with all changes. I have been using preparedStatements to update my database and I have 8 parameters for my first command, however, only 3 of the parameters are recognized. I have checked the SQL statement repeatedly in Access and have determined that it is not the cause.

My code goes as follows:

preparedStatement contactUpdate = "Update tblContact Set FirstName = '?', LastName = '?', Suffix= '?', DOB = '?',Address = ?...(other inserts)... Where contactID = ?";

contactUpdate.setString(1,"Jimbo");
contactUpdate.setString(2,"Delacroix");
contactUpdate.setString(3,"III");
contactUpdate.setDate(4,Date);
//Error right here on the next line.
contactUpdate.setInt(5, 32);
contactUpdate.setString(6,"Jimbo");
contactUpdate.setString(7,"Jimbo");
contactUpdate.setString(8, 1);

contactUpdate.execute();

If you have any suggestions please let me know.


“A man can do anything, he must merely choose to do so.” -Miyamoto Musashi
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

Tom,
Welcome to JavaRanch!

I may be missing the obvious here, but what error message do you get?

Does it work if you hardcode "address = 1" instead of using the prepared statement? This will tell you if the error is in the SQL part or the prepared statement part. Which will help someone here give you more specific advice.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error Setting parameters in a Update preparedstatments