I am a beginner and I tried to do a program involving JDBC involving mySQL.
The program displays a menu that lets the user to choose an option. I used a switch and from there, I call the methods.
I haven't written the code for the delete method yet.
When I run the insert method, it errs saying, Error: com.mysql.jdbc.exceptions.jdbc4.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 ''Dan','Vuyyur',7845)' at line 1 Someone please tell me what I have done wrong. Is it like the mismatch in the datatypes? The datatype of the field in the mySQL table and the int declared here in Java?
I think you've got your INSERT statement syntax wrong. Try:
(obviously change it to whatever your actual column names are).
Are you sure you want to store phone numbers using a numeric type? A string would be much more common. You can have numbers that start with a 0 which will be removed in a number. You also might want spaces or other formatting, and possible international numbers (using +). And you never need to carry out arithmetic on a phone number.
Joined: Mar 04, 2013
Thank you so much. I didn't check the query. As I thought it is something more complicated. Thank you, sir. And I was just practicing, later on, I will take the phone as a String.
And I couldn't figure out how to reply to you. @Matthew Brown.