I have a table, say example1 and I’m using a jdbc statement to delete one of its rows. I have tried various methods, from delete from example1 where id = 1 to statement.addbatch(sql) but it does not delete the row. If I execute the same sql statement in Toad for Mysql it’s able to delete the row just fine.
Weird thing is that using jdbc I am able to delete rows from other tables just fine; it’s just this one particular table giving me unexpected results.
There is nothing special about this table. It has a primary key and no constraints/foreign key relationships.
Also, this delete is a part of a transaction so auto-commit is set to false and once all records get updated/inserted/deleted then the commit is done. This does not seem to have any problem with any other table and all the updates/deletes/inserts are done just fine.
Permission-wise this table has same permission for the db user that any other table in the db.
Any ideas or pointers will be greatly appreciated!
Turning on general logging on the database or profiling in the JDBC driver would show you what’s actually going to the database:
http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configuration-properties.html
Enable profiling of queries for Connector/J by adding this to your connection string: profileSQL=true
General Logging documentation:
http://dev.mysql.com/doc/refman/5.1/en/query-log.html
There’s also mk-query-digest for sniffing your network traffic and analyzing the results:
http://www.maatkit.org/doc/mk-query-digest.html