Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8366293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:52:50+00:00 2026-06-09T12:52:50+00:00

I got some strange problem. I use a Pool to create and manage DB

  • 0

I got some strange problem.

I use a Pool to create and manage DB Connections, I set the DefaultAutocommit option to FALSE.

But after a while, when an error occur and a rollback is called an Exception is thrown : Can't call rollback when autocommit=true

Relaunching JBoss will solve the problem as a new DataSource will be created.

Here is how I create my Datasource :

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);
}

And how I get the connections :

xxx.getDataSource().getConnection();

I didn’t try yet but my first call will be to force the autocommit directly on the connection using setAutoCommit(false).

Though I don’t understand why the poolProperties.setDefaultAutoCommit(false); is stopping doing the job.

Stack trace :

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)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:52:51+00:00Added an answer on June 9, 2026 at 12:52 pm

    So here is what is in place today, I force the AutoCommit attribute on each connection created by the pool.

    This works, so it definitely may be a bug of the pool classes.

    Edit:
    I also had a problem with transaction isolation that was set the same way but not taken into account. After some research I found that this could be related to the Mysql connector/J I use (http://dev.mysql.com/doc/refman/5.1/en/connector-j-reference-configuration-properties.html) .

    I found this interesting parameter in the doc :

    useLocalSessionState

    Should the driver refer to the internal values of autocommit and
    transaction isolation that are set by Connection.setAutoCommit() and
    Connection.setTransactionIsolation() and transaction state as
    maintained by the protocol, rather than querying the database or
    blindly sending commands to the database for commit() or rollback()
    method calls?

    Default value : false

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Got some strange problem, when i use $.post to a php file. The file
I've got a quite strange problem here. I'm calling some simple code via Ajax.Updater:
I just got a strange problem. I am including some files from my index.php,
I got some strange problem with my WebView. The problem is that I can't
I've got some strange problem with GZip Serializer. Trying serializing object with data in
Ive got a really strange problem with some javascript code that ive written. I
I've got a strange problem here. Assume that I have a class with some
I have some strange problem. I think I followed documentation correctly but my code
I've got a strange problem with a php file. I'm trying to get some
I've got some strange bug: when I open page first time in some browser

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.