I know that MySQL supports this query (ON DUPLICATE KEY UPDATE) for example:
INSERT INTO UserFailure (Realm, Username, DateOfFailure, CountOfFailure) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE CountOfFailure=?;
When I am running this on embedded Derby DB it gives me:
PreparedStatementCallback; bad SQL grammar [INSERT INTO UserFailure (Realm, Username, DateOfFailure, CountOfFailure) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE CountOfFailure=?;]; nested exception is java.sql.SQLSyntaxErrorException: Syntax error: Encountered "ON" at line 1, column 91.
I assume that Derby does not support this feature.
Is there a query I can use to update the database record on duplicate key from Derby and from MySQL?
You can catch the duplicate key exception yourself, and issue the update.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With