Ukraine1449
Ukraine1449

Reputation: 29

Syntax error with mysql database using JDBC

PreparedStatement posted = con.prepareStatement(
    "INSERT INTO userdate (description, UUID) VALUES ('"+ desc + "','" + postuuid + "') ON DUPLICATE KEY UPDATE");

this is the error 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 '' this is the code I have, does anyone know waht might be wrong with this?

Upvotes: 0

Views: 67

Answers (1)

Craig
Craig

Reputation: 1226

Check on MySQL docs for reference on DUPLICATE KEY UPDATE https://dev.mysql.com/doc/refman/8.0/en/insert-on-duplicate.html

The keyword "UPDATE" is not the absolute end of the statement. You need to specify the fields/values that will be updated

Upvotes: 1

Related Questions