aspose 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 Java 8 in Action this week in the Java 8 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: 18150
    
    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: 52

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
 
Similar Threads
a mistake for bean
ClassNotFoundException generated!
No Suitible Driver Error
MS Access NullPointerException
Access to the Oracle database using Java Applets