2011-04-14 43 views
0

一個簡單的問題真的,爲此,我似乎無法找到答案,我不打算重新配置DB登錄查詢....MySQL的JDBC驅動程序 - 查詢包裝?

的問題是:驅動程序自動換行的所有SQL查詢/更新到

START TRANSACTION; MyQuery; COMMIT;

或者有沒有辦法配置它來做到上述?

謝謝。

回答

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. 
+0

感謝,正是我一直在尋找因爲 - 沒有看到它在API第一次周圍:( – Sigtran 2011-04-14 08:22:17

1

默認情況下,JBDC自動提交模式是真實的,我們可以用連接對象設置 請參閱例如

JDBC Autocommit

希望幫助

+0

是的,謝謝,我已經閱讀API的第一個答案,並得到它的工作,因爲我想。 – Sigtran 2011-04-14 08:36:12