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 6183413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:21:39+00:00 2026-05-24T01:21:39+00:00

* UPDATE: I found a method which didn’t close the session after openning. I

  • 0

*UPDATE: I found a method which didn’t close the session after openning. I think this might be the cause. Will test and report later. *

We are using MyBatis with our GWT Java web application. The problem is that sometimes an exception happens while trying to read or write to the database with MyBatis. What could be the cause? Any subsequent queries will work. It seems like the connection is timed out and needs to be refreshed. This happens sometimes through the day, we don’t see any pattern in this. We tried different configurations to no avail.

org.apache.ibatis.exceptions.PersistenceException: 
### Error opening session.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Communications link failure during rollback(). Transaction resolution unknown.
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Communications link failure during rollback(). Transaction resolution unknown.

The MyBatis configuration file:

<environments default="development">
    <environment id="development">
        <transactionManager type="JDBC" />
        <dataSource type="POOLED">
            <property name="driver" value="com.mysql.jdbc.Driver"/>     

            <property name="url" value="jdbc:mysql://localhost/project"/>
            <property name="username" value="username"/>
            <property name="password" value="password"/>

            <property name="poolMaximumActiveConnections" value="20"/>
            <property name="poolMaximumIdleConnections" value="5"/>
            <property name="poolPingEnabled" value="true"/>
            <property name="poolPingQuery" value="select 1"/>

        </dataSource>
    </environment>
</environments>

Update 1
The exception is thrown in different “DAOs”, it’s not specific to a single method/call.
A general method might look like this:

@Override
public Entity get(String id) throws Exception {
    LogHelper.logMethodStart(logger, "get", "id", id);

    SqlSession session = null;
    try {
        session = GenericDao.SESSION_FACTORY.openSession();
        EntityDao mapper = session.getMapper(EntityDao.class);
        return mapper.get(id);
    } catch (Exception e) {
        logger.error(e);
        throw e;
    } finally {
        if (session != null) {
            session.close();
        }
    }

}

Where the session factory class consists of:

public static SqlSessionFactory SESSION_FACTORY;

static {
    logger.info("SqlSessionFactory init started.");

    String aResource = "iBatisConfig.xml";
    Reader reader;
    try {
        reader = Resources.getResourceAsReader(aResource);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    SESSION_FACTORY = new SqlSessionFactoryBuilder().build(reader);

    try {
        reader.close();
    } catch (IOException e) {
        logger.error(e);
    }

    SESSION_FACTORY.getConfiguration().addMappers("com.example.project.server.dao");

    logger.info("SqlSessionFactory init end.");
}
  • 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-05-24T01:21:40+00:00Added an answer on May 24, 2026 at 1:21 am

    Problem solved for me. I went though all the methods that were opening a session and one session was not being closed – coding error. Thus the connection pool ran out of free connection sometimes.

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

Sidebar

Related Questions

Inspired by this question. Why is there no list.clear() method in python? I've found
All the documentation I've found so far is to update keys that are already
UPDATE - A comprehensive comparison, updated as of February 2015, can be found here:
Update: Check out this follow-up question: Gem Update on Windows - is it broken?
Update: Now that it's 2016 I'd use PowerShell for this unless there's a really
UPDATE: Thanks to everyone for the responses. I didn't realize document.write() was deprecated. Add
Update: Thanks for the suggestions guys. After further research, I’ve reformulated the question here:
Update There is no ready XML parser in Java community which can do NIO
I have found this example on StackOverflow: var people = new List<Person> { new
I would like to update my SQL lite database with the native update-method of

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.