Home:ALL Converter>How to check a connection to MySQL db is not dead, and avoid unnecessarily (close and) re-create connection?

How to check a connection to MySQL db is not dead, and avoid unnecessarily (close and) re-create connection?

Ask Time:2012-09-22T03:19:16         Author:qazwsx

Json Formatter

How to check a connection to MySQL db is not dead, and avoid unnecessarily (close and) re-create connection? Say, I am creating and using the connection in a Bash script.

Edit

By "dead" i mean, perhaps the last time when a created connection was used is 1 hr ago, and on the server side, perhaps it does something to kill off inactive connections in some way.

Author:qazwsx,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/12536888/how-to-check-a-connection-to-mysql-db-is-not-dead-and-avoid-unnecessarily-clos
yy