This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Prepared Statement problem in my servlet's data manager

 
John Turner
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the column names are left out...

String strUpdate = "INSERT INTO mdb (column_names) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
 
Paul Clapham
Sheriff
Posts: 21126
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 54
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic