MySQL的JDBC驱动程序 - 查询包装?

时间:2011-04-14 08:12:08

标签: mysql jdbc wrapping

一个简单的问题,我似乎无法找到答案而且不会重新配置数据库以记录查询....

问题是:驱动程序是否自动将所有SQL查询/更新包装到

START TRANSACTION; MyQuery; COMMIT;

或者有没有办法配置它来执行上述操作?

感谢。

2 个答案:

答案 0 :(得分:1)

请参阅Connection.setAutoCommit(boolean autoCommit)
这是JDK文档中的描述。

   Sets this connection's auto-commit mode to the given state. If a connection is in 
auto-commit mode, then all its SQL statements will be executed and committed as individual 
transactions.Otherwise, its SQL statements are grouped into transactions that are terminated 
by a call to either the method commit or the method rollback. By default, new connections are
 in auto-commit mode. 

答案 1 :(得分:1)

默认情况下,JBDC自动提交模式为true,我们可以使用连接对象进行设置 请看示例

JDBC Autocommit

希望有所帮助