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 Prepared Statement problem in my servlet's data manager Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Prepared Statement problem in my servlet Watch "Prepared Statement problem in my servlet New topic
Author

Prepared Statement problem in my servlet's data manager

John Turner
Greenhorn

Joined: Dec 19, 2010
Posts: 6
Hi all,

I am having trouble with a prepared statement in my Java Servlet's data manager where it inserts a member into the database. I believe the syntax is correct, but I always seem to get the error:



Here is my code




Hope you can help me solve this problem.
Tim McGuire
Ranch Hand

Joined: Apr 30, 2003
Posts: 820

First step to solve this. is to back up and run that SQL in a SQL editor like dbvisualizer or Toad for MYSQL and see if it works there.
laila NiHai
Ranch Hand

Joined: Oct 18, 2010
Posts: 35
I think the column names are left out...

String strUpdate = "INSERT INTO mdb (column_names) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18985
    
    8

The error is in line 41 of the code you posted. Review the API documentation for PreparedStatement. In particular the documentation for the executeUpdate method.
Deepakkumar Devarajan
Ranch Hand

Joined: Apr 19, 2011
Posts: 54

Yes,Paul Clapham is right. The method prepareStatement holds parameterized SQL statements that needs to be sent to the database. So while calling executeUpdate, no parameter is required.


Regards,
Deepakkumar Devarajan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Prepared Statement problem in my servlet's data manager