开发者

JDBC statement fails to delete row in specific MySql table

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 une开发者_如何转开发xpected 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


I have come across the same situation

I remember there was a defnitely mistake in the query Try to execute the query in the mysql sqlyog or any GUI and check if it works, i am 100% sure it wont work

then correct the query and check it

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜