MyBatis Connection MySQL Report exception: No operations allowed after connection closed. Connection was implicitly closed

Source: Internet
Author: User
Tags connection pooling

The website runs one night, comes to work in the morning, found the error:

# # # Error querying database. Cause:com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:No operations allowed after connection Closed.

Checked online, because the default configuration is used, idle for more than 8 hours, automatically disconnect the connection

I used the default connection pool for MyBatis, so I configured the matching. DataSource properties, refer to MyBatis official documentation

        <EnvironmentID= "Env_stg">            <TransactionManagertype= "JDBC" />            <DataSourcetype= "Pooled">                < Propertyname= "Driver"value= "${driver}" />                < Propertyname= "url"value= "${url_stg}" />                < Propertyname= "username"value= "${username}" />                < Propertyname= "Password"value= "${password}" />                < Propertyname= "Poolmaximumactiveconnections"value= " the"/>                < Propertyname= "Poolmaximumidleconnections"value= "5"/>                <!--mysqlnontransientconnectionexception:no operations allowed after connection closed -                < Propertyname= "Poolpingquery"value= "Select 1"/>                < Propertyname= "poolpingenabled"value= "true"/>                <!--one-hour check for idle connections -                < Propertyname= "Poolpingconnectionsnotusedfor"value= "3600000"/>            </DataSource>        </Environment>

Reference: http://fengbin2005.iteye.com/blog/1906488

A great article: "In-depth understanding of mybatis principles" mybatis data sources and connection pooling

MyBatis Connection MySQL Report exception: No operations allowed after connection closed. Connection was implicitly closed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.