Meaningless Drivel is fun!
The moose likes JDBC and Relational Databases 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
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Prepared Statement problem in my servlet Watch "Prepared Statement problem in my servlet New topic

Prepared Statement problem in my servlet's data manager

John Turner

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

Joined: Oct 14, 2005
Posts: 19973

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.

Deepakkumar Devarajan
I agree. Here's the link:
subject: Prepared Statement problem in my servlet's data manager
It's not a secret anymore!