This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi All I have written a program using Servlets and JSP where am trying to enter data into database(MySQL) using the JSP page. But I'm getting a MySQLSyntaxErrorException after submitting the data from the JSP page. Here are the servlet and JSP programs...
Using the following versions: MySQL 5.0, Tomcat 6, MySQL Connector-J 5.1.7, Eclipse IDE.
Error on Tomcat console:
My database entries seem to be perfect and I'm not able to find the problem with my syntax. Can any one help me out to trace out the problem?
Thanks & Regards
I "try", I "catch" and "finally" WIN !!!
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error inyour SQL syntax; check the manual that corresponds to your MySQL server versionfor the right syntax to use near 'ComponentDetails('asjdhk','akahdsfkja',3947,'sjhfka','kadhf',3947319,'1234-12-12' at line 1
This says the error.
Insert statements start with INSERT INTO tablename (......) VALUES (....) But you have two identifiers after INSERT INTO.., are both the table name or what?
Originally posted by Swapna Gouri Kalanidhi: Here's the rectified code Vijitha
Will be very grateful to you if you can help me in solving this problem...
There are two forms for a SQL insert statement.
The first form doesn't specify the column names where the data will be inserted, only their values (you insert all the columns in order):
This seems to be the format of your statement. However, you're still not including the VALUES clause before your column values. Add the VALUES clause before your parentheses and make sure you're have all your columns specified in order.
The second form specifies both the column names and the values to be inserted:
Use this one if you're not including all the columns... and don't forget your VALUES clause.
Swapna Gouri Kalanidhi
Joined: Mar 14, 2008
Hi Campbell Thanks a ton! I have inserted "Values" and it worked !