我正在使用DB2。我爲它創建了ConnectionPool。一些查詢需要在「aumoCommit = false」模式下執行。autoCommit var是否在c3p0中重置?
Connection con = ConnectionPool.getConnection // wrapper
con.setAutoCommit(false);
PreparedStatment ps = con.prepareStatement(// query...);
ps.setString(...);
ps.executeUpdate();
con.commit();
ps.close();
con.close();
con.setAutoCommit(true); // should be here ?
的問題是:我應該補充con.setAutoCommit(真)線在年底或C3P0重置的每一個封閉(返回到池)連接狀態?
編輯:經過一些評論,我補充說,我的問題是:應該con.setAutoCommit(false)調用一般在那裏或c3P0復位狀態的這個連接和nexct時間這個連接將在con.setAutoCommit(false ) 默認?
調用'setAutoCommit'你關閉了連接(它返回到池)應觸發一個例外,因爲該邏輯手柄現在應該表現得好像自己真的關閉後。 –
@MarkRotteveel我的問題不是關於在哪裏調用setAutoCommit(false),它應該更一般地稱爲它? – megabobik
行爲良好的連接池應該將連接重置爲初始狀態,就像它是JDBC規範中描述的全新連接一樣,但並非所有連接池都這樣做;不確定C3P0。 –