2

Error:

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'lock WHERE player='SrLolok'' at line 1

Code:

PreparedStatement search = instance.getConnection().prepareStatement("SELECT * FROM lock WHERE player=?;");
search.setString(1, player);
ResultSet rs = search.executeQuery();
1
  • The error message you got has a big clue that the problem is with the word "lock", because it's the first part of what it shows you in the query: ...syntax to use near 'lock WHERE .... The part right after "near" is usually a good indicator of something you're doing wrong. Commented Jan 28, 2020 at 17:16

1 Answer 1

5

lock is a reserved word in MySQL.

If you want to use it, you need to surround it with backticks:

SELECT * FROM `lock` WHERE player=?

Or better yet, use a table name that does not correspond to a reserved word, so you don't need to worry about this.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.