Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Tuesday, December 22, 2015

MYSQL 8 Hours Time out Problem

MYSQL 8 Hours Time out Problem


I am using MYSQL 5.0 and Tomcat 5.5. After 8 hours , MYSQL closes by default closes all idle connections and so I am getting an SQL Exception .Any solution to this problem

Answer by Jon Skeet for MYSQL 8 Hours Time out Problem


Which connection pool are you using? Most allow a heartbeat command to be executed periodically to keep connections from idling out.

EDIT: Looking at the DBCP configuration page, I think you should set an appropriate (cheap) validationQuery. You could then either tell DBCP to test this when potentially evicting idle connections (testWhileIdle) or tell it to test just before returning the connection (testOnBorrow). The first would (hopefully!) keep your idle connections alive; the second wouldn't, but wouldn't return you broken connections (i.e. if would create a new one if necessary).

Answer by Fredrik Mörk for MYSQL 8 Hours Time out Problem


Do you mean that you keep the connections alive while they are idle? I am no expert on mySql, but in the databases I have been working with it's considered good practice to keep the connection open only while it's needed, and then close it.

Answer by Chathuranga Chandrasekara for MYSQL 8 Hours Time out Problem


I don't know how to increase the timeout but I guess there should be a setting.. Why don't you create the connection when you need it, and close it after using it other than depending on a created connection?

Answer by Danny D'Amours for MYSQL 8 Hours Time out Problem


With MySQL, by default an open connection (often waiting in a connection pool) will be closed after 8 hours of inactivity. You can change this time from 8 hours by configuring the wait_timeout variable either in your my.cnf or on our mysql command line

See: http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_wait_timeout http://dev.mysql.com/doc/refman/5.0/en/gone-away.html

Answer by Edson H Philippe for MYSQL 8 Hours Time out Problem


This question has been asked a few years ago, but I feel that it's good to have the correct answer. i had the same issue, to solve I had to play with the configuration a little bit. here is what works for me. Go on https://people.apache.org/~fhanik/jdbc-pool/jdbc-pool.html for more info. The code below took care of everything. There is way to optimize the values but I will take care of these later.

  


Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.