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?
Mark Rotteveel
110k241 gold badges160 silver badges233 bronze badges
1 Answer 1
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
Sign up to request clarification or add additional context in comments.
1 Comment
Ukraine1449
Thank you this helped. This is my new code: PreparedStatement posted = con.prepareStatement("INSERT INTO userdata(description, UUID) VALUES ('"+desc+"', '"+postuuid+"') ON DUPLICATE KEY UPDATE description='"+ desc +"'");
default
?) instead of values.