After a period of time, the MySQL-based Web site will often be in a status that cannot respond, or the response is very slow, because the database connection is automatically closed. Run show variables like '% timeout %' in MySQL Command Line Client'
We can see two variables wait_timeout and interactive-timeout. Their default values are 28800 seconds, that is, 8 hours. That is to say, by default, Mysql will automatically close the opened connection after eight hours (28800 seconds) are not used. Www.2cto.com 1. to solve this problem, for versions earlier than MySQL5, such as Mysql4.x, you only need to modify the URL in the connection pool configuration and add a parameter: autoReconnect = true. For versions earlier than MySQL5, you need to modify my. cnf (or my. ini) file, after [mysqld]: wait_timeout = n interactive-timeout = n is the number of seconds waiting for activity before the server closes the interactive connection. Www.2cto.com 2. ruguoc3p0 connection pool solution <property name = "testConnectionOnCheckout" value = "false"/> <property name = "testConnectionOnCheckin" value = "false"/>
If the attribute is true, it can be solved. Because of high performance consumption, please use it only when needed. If it is set to true, the validity of each connection is verified when it is submitted. We recommend that you use idleConnectionTestPeriod or automaticTestTable to improve the connection test performance. <property name = "idleConnectionTestPeriod" value = "60"/> check the idle connections in all connection pools every several seconds, the default value is 0, indicating no check; <property name = "automaticTestTable" value = "c3p0_connection_testtable"/> chaunceyhao