Leo Chan wrote:
> Hi,
>
> I have a MySQL server and client running at the
> same server. However, when running long times
> ~few hrs, it will come out some Exception as
[snip]
> This kind of error came out in random. As I
> run the client and server at same host(localhost
> in driver setting) so it should not have network
> problem cause broken pipe. The MySQL version I
Leo,
Whether or not the server is remote or local has little to do with whether TCP/IP connections can have network problems.
The problem you're experiencing is because you've configured your connection pool to let connections remain in an idle state for longer than what the server will allow. The server reclaims connections that have been idle for quite some time, as it is a waste of resources. There's not a lot of situations where it makes sense to let connections sit idle for _hours_.
> use is 4.1.8 and JDBC Driver is 3.1.10. The
> socketTimeout of the driver has been set to"0". I
> use connection pool so that every connection is
> reused but not "new" on demand.
>
> Please help to advise what's wrong.
The fix for this is covered in the documentation:
http://dev.mysql.com/doc/mysql/en/cj-faq.html
For an example of a way of configuring a connection pool to not allow long idle times, see:
http://dev.mysql.com/doc/mysql/en/cj-tomcat-config.html
-Mark
Mark Matthews
Consulting Member Technical Staff - MySQL Enterprise Tools
Oracle
http://www.mysql.com/products/enterprise/monitor.html