title: Auto-commit changes to TRUE after a while using a connection pool
body: <p>I got some strange problem. </p>
  
  <p>I use a Pool to create and manage DB Connections, I set the <code>DefaultAutocommit</code> option to <code>FALSE</code>.</p>
  
  <p>But after a while, when an error occur and a <code>rollback</code> is called an Exception is thrown : <code>Can't call rollback when autocommit=true</code></p>
  
  <p>Relaunching JBoss will solve the problem as a new DataSource will be created.</p>
  
  <p>Here is how I create my Datasource :</p>
  
  <pre><code>protected DataSource getDataSource(String driverClassName, String dbUrl, String dbUser, String dbPwd) {
      PoolProperties poolProperties = new PoolProperties();
      poolProperties.setUrl(dbUrl);
      poolProperties.setDriverClassName(driverClassName);
      poolProperties.setUsername(dbUser);
      poolProperties.setPassword(dbPwd);
  
      poolProperties.setDefaultAutoCommit(false);
      poolProperties.setTestWhileIdle(false);
      poolProperties.setTestOnBorrow(true);
      poolProperties.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
      poolProperties.setValidationQuery("SELECT 1");
      poolProperties.setTestOnReturn(false);
      poolProperties.setLogAbandoned(false);
      poolProperties.setRemoveAbandoned(true);
      poolProperties.setRemoveAbandonedTimeout(20);
      poolProperties.setMaxActive(100);
      poolProperties.setInitialSize(10);
      poolProperties.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
  
      return new DataSource(poolProperties);
  }
  </code></pre>
  
  <p>And how I get the connections :</p>
  
  <pre><code>xxx.getDataSource().getConnection();
  </code></pre>
  
  <p>I didn't try yet but my first call will be to force the autocommit directly on the connection using <code>setAutoCommit(false)</code>.</p>
  
  <p>Though I don't understand why the <code>poolProperties.setDefaultAutoCommit(false);</code> is stopping doing the job.</p>
  
  <p>Stack trace :</p>
  
  <pre><code>com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Can't call rollback when autocommit=true
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
      at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
      at com.mysql.jdbc.Util.getInstance(Util.java:384)
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015)
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:929)
      at com.mysql.jdbc.ConnectionImpl.rollback(ConnectionImpl.java:4805)
      at sun.reflect.GeneratedMethodAccessor302.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.apache.tomcat.jdbc.pool.ProxyConnection.invoke(ProxyConnection.java:125)
      at org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:94)
      at org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor.invoke(AbstractCreateStatementInterceptor.java:71)
      at org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:94)
      at org.apache.tomcat.jdbc.pool.interceptor.ConnectionState.invoke(ConnectionState.java:140)
      at $Proxy333.rollback(Unknown Source)
  </code></pre>