Mysql connection is idle for 8 hours and automatic disconnection problem DBCP Solution

Source: Internet
Author: User
Welcome to the Oracle community forum and interact with 2 million technical staff. The default "wait_timeout" on the Mysql server is 8 hours. That is to say, if a connection is idle for more than 8 hours, Mysql will automatically disconnect the connection. If connections is idle for more than 8 hours, Mysql disconnects it, and DBCP does not know that the connection has

Welcome to the Oracle community forum and interact with 2 million technical staff> the default "wait_timeout" on the Mysql server is 8 hours. That is to say, a connection is idle for more than 8 hours, mysql will automatically disconnect the connection. If connections is idle for more than 8 hours, Mysql disconnects it, and DBCP does not know that the connection has

Welcome to the Oracle community forum and interact with 2 million technical staff> enter

The default "wait_timeout" of the Mysql server is 8 hours. That is to say, if a connection is idle for more than 8 hours, Mysql will automatically disconnect the connection. If connections is idle for more than 8 hours, Mysql will disconnect it, and DBCP does not know that the connection has expired. If a Client requests a connection at this time, DBCP will provide the invalid Connection to the Client, this will cause the above exception.

In mysql configuration, the wait_timeout value of my. cnf must be greater than or equal to the idle_timeout value of the connection pool. Otherwise, mysql closes the connection after the wait_timeout time. However, the connection pool considers the connection to be available, which causes an exception.

Org. apache. jasper. jasperException: javax. servlet. servletException: javax. servlet. jsp. jspException: Communications link failure Last packet sent to the server was 1 MS ago. org. apache. jasper. servlet. jspServletWrapper. handleJspException (JspServletWrapper. java: 522) org. apache. jasper. servlet. jspServletWrapper. service (JspServletWrapper. java: 398) org. apache. jasper. servlet. jspServlet. serviceJspFile (JspServlet. java: 342) org. apache. jasper. servlet. jspServlet. service (JspServlet. java: 267) javax. servlet. http. httpServlet. service (HttpServlet. java: 717)

DBCP connection pool description: driverClassName url username password the four above are drivers, connection strings, user names, and passwords respectively.

Maximum number of connections supported by maxActive connection pool

Maximum number of idle maxIdle connections in the maxIdle connection pool

The minimum number of idle maxIdle connections in the minIdle connection pool

InitialSize initial connection count

New request wait time (in milliseconds) when the connection in the maxWait connection pool is used up

TimeBetweenEvictionRunsMillis and minEvictableIdleTimeMillis are used together. Each timeBetweenEvictionRunsMillis checks idle connections in the connection pool in milliseconds, and disconnects connections with idle time exceeding minEvictableIdleTimeMillis in milliseconds, until the number of connections in the connection pool reaches minIdle, it is good to add these two parameters.

MinEvictableIdleTimeMillis connection pool idle time,

Millisecond removeAbandoned true, false, whether to clear

RemoveAbandonedTimeout seconds are not used for active connections. After cleaning, the connection pool is not put back.

Maximum idle time of the removeAbandonedTimeout active connection

LogAbandoned true, false: whether to print messages when the connection pool recovers idle active connections

MinEvictableIdleTimeMillis, removeAbandonedTimeout parameters are not similar to connection objects.

MinEvictableIdleTimeMillis is the connection object in the connection pool,

RemoveAbandonedTimeout for unclosed active connections

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.