开发者

JDBC driver for MySQL - Query Wrapping?

开发者 https://www.devze.com 2023-02-24 08:04 出处:网络
a simple question really, for which I cant seem to find an answer and am not going to reconfigure DB to log queries....

a simple question really, for which I cant seem to find an answer and am not going to reconfigure DB to log queries....

The question is: Does t开发者_StackOverflow社区he driver automatically wraps all SQL queries/updates into

START TRANSACTION; MyQuery; COMMIT; ?

Or is there a way to configure it to do the above?

Thanks.


Please refer to Connection.setAutoCommit(boolean autoCommit)
Here's its description from JDK document.

   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. 


By default, JBDC autocommit mode is true, and we can set it with connection object please see example

JDBC Autocommit

hope that helps

0

精彩评论

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