jQuery in Action, 3rd edition
The moose likes JDBC and Relational Databases and the fly likes MYSQL error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "MYSQL error" Watch "MYSQL error" New topic
Author

MYSQL error

Hrishikesh Maluskar
Ranch Hand

Joined: Jun 19, 2008
Posts: 115
i am getting the following error.
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@yahoo.com,1,1,77,77,0,1,77,77)' at line 1


my SQL is as follows->


SCJP 1.5
www.licexpadvice.com
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2543
    
  10

Your error is not coming from this statement. Can you post the exact code that caused the problem?


OCUP UML fundamental and ITIL foundation
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3740
    
  10

This is the type of SQL error message that you should read carefully. Clearly, you have an error in the statement going to the server. Try turning on JDBC logging and outputting the exact SQL statement that goes to the MySQL server then run it inside of a SQL client tool. That should have you find out whats wrong with your SQL string.


[OCA 8 Book] [Blog]
Hrishikesh Maluskar
Ranch Hand

Joined: Jun 19, 2008
Posts: 115
my java code is as follows->

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 44038
    
  33
I edited your post because the lines were too long. As well as something wrong with the syntax, I suspect your database design. I suspect you might have too many columns in that table; things like first name are not attributes of a flat so much as the landlord/landlady. The landlord and landlady merit a table of their own. The values you inserted in the first example you showed appear to be different from the names of the columns, which makes your problem more difficult to analyse.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 32507
    
214

Hrishikesh,
That SQL is missing the single quotes around the String fields. It should be


Note you really should be using a PreparedStatement rather than concatentating user values to prevent a SQL Injection attack.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Hrishikesh Maluskar
Ranch Hand

Joined: Jun 19, 2008
Posts: 115
very very thanks Jeanne , i wasted 2 days for this problem.
 
Have you checked out Aspose?
 
subject: MYSQL error
 
It's not a secret anymore!