0

I am new to Java. I received an error in my project while compiling in Java.

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

'exit values('1234567','aaa','aaa','aaa','aaa','aaa',0)' at line 1.

Screenshot of Code and Error

Community
  • 1
  • 1
  • 2
    Please include the complete query – Sree KS Jul 15 '16 at 05:25
  • please provide the neccessary code aswell – SomeJavaGuy Jul 15 '16 at 05:25
  • 1
    Welcome to Stack Overflow. Your question is not answerable because you omitted the code and SQL query involved in your problem. – Tim Biegeleisen Jul 15 '16 at 05:25
  • In case no one else mentions it: please [edit] your question's title to something meaningful that relates to your question. Also, you should read [How do I ask a good question?](http://stackoverflow.com/help/how-to-ask) – Jonny Henly Jul 15 '16 at 05:27
  • 1
    Try to change name of table 'exit' to some other value – Rashid Jul 15 '16 at 05:27
  • 2
    For future and current reference: don't include an image of your code, include the actual (relevant) code copy-pasted from your IDE in a well formatted manner. – Jonny Henly Jul 15 '16 at 05:30
  • 1
    Thanx for such a fast reponse @Sree; @Kevin Esche; @ Tim Biegeleisen...I will take care for next time @ Jonny Henly ...and really worked @ Rashid...Thanx ..thanx a lot .. – Kavit Bansal Jul 15 '16 at 05:40
  • 1
    No, take care of it for THIS TIME, or your question will likely get closed. – Jim Garrison Jul 15 '16 at 05:40

2 Answers2

2

exit is a MySQL reserved word and is not allowed as a table name in SQL statements.

Rename the table, or if you really want to use this table name, then put it in backticks:

insert into `exit` values (?,?,?,?,?,?,?)
Jesper
  • 202,709
  • 46
  • 318
  • 350
2

Refer to this SQL manual

An identifier may be quoted or unquoted. If an identifier contains special characters or is a reserved word, you must quote it whenever you refer to it. (Exception: A reserved word that follows a period in a qualified name must be an identifier, so it need not be quoted.) Reserved words are listed at Section 10.3, “Keywords and Reserved Words”.

This StackOverflow answer exactly addresses your query as to how to use reserved words as an identifier.

Community
  • 1
  • 1