Skip to content

Instantly share code, notes, and snippets.

@swkwon
Last active December 28, 2015 00:09
Show Gist options
  • Save swkwon/7411069 to your computer and use it in GitHub Desktop.
Save swkwon/7411069 to your computer and use it in GitHub Desktop.
MySql에서는 connection을 Open한 후 wait_timeout이 만료 될때까지 아무런 request가 없으면 DB Server에서 connection을 끊어버립니다. Application에서는 connection을 사용하기 전에 항상 ping을 날려 상태를 파악한 후 다시 Open해주어야 합니다. 기본 timeout은 28800초 즉, 8시간 입니다.
MySqlConnection conn = new MySqlConnection(connStr);
conn.Open();
// no job until expired wait_timeout... default timeout is 28800 seconds.
conn.Ping();
if (conn.State == System.Data.ConnectionState.Closed)
conn.Open();
// Then you can use connection!
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment