I'm executing the same sql command having ON DUPLICATE KEY UPDATE v=v in 2 ways.
Command: INSERT INTO VS (v) VALUES ('someValue') ON DUPLICATE KEY UPDATE v=v;
Two way giving different results:
- When using a native mysql client and a constraint is met, the number of rows affected is 0. Message:
Query OK, 0 rows affected (0.14 sec) - When using mysql jdbc driver (
mysql-connector-java-8.0.11.jar), and executing the same command usingint res = ps.executeUpdate(...), the result is 1.
From the java documentation, the result is the the row count for SQL Data Manipulation Language (DML) statements, but no update, nor inserts were made.
Also, calling ps.getUpdateCount(), after the execute, returns 1 as well.
Why is the result in the mysql java driver 1, where nothing was supposed to be updated? Thanks.
Just for clarity, the table creation looks like this:
CREATE TABLE IF NOT EXISTS VS (v VARCHAR(128) NOT NULL, PRIMARY KEY (v))