Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting duplicate count when executing INSERT IGNORE via JDBC

Tags:

mysql

insert

jdbc

Is it possible to get the duplicate count when executing MySQL "INSERT IGNORE" statement via JDBC?

For example, when I execute an INSERT IGNORE statement on the mysql command line, and there are duplicates I get something like

Query OK, 0 rows affected (0.02 sec) Records: 1 Duplicates: 1 Warnings: 0

Note where it says "Duplicates: 1", indicating that there were duplicates that were ignored.

Is it possible to get the same information when executing the query via JDBC?

Thanks.

like image 815
Nickolay Komar Avatar asked Nov 18 '25 19:11

Nickolay Komar


1 Answers

I believe you can retrieve this by issuing SHOW WARNINGS after your insert.

http://dev.mysql.com/doc/refman/5.0/en/show-warnings.html

like image 92
Joshua Martell Avatar answered Nov 21 '25 08:11

Joshua Martell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!