장시간(확인한 바로는 10시간 넘게..) MySQL이 idle 상태면 커넥션이 닫혀버린다.

그래서 MySQLNonTransientConnectionException 이 발생하게 되는데... (자바에서)


아래는 참고문서

http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configuration-properties.html

autoReconnect Should the driver try to re-establish stale and/or dead connections? If enabled the driver will throw an exception for a queries issued on a stale or dead connection, which belong to the current transaction, but will attempt reconnect before the next query issued on the connection in a new transaction. The use of this feature is not recommended, because it has side effects related to session state and data consistency when applications don't handle SQLExceptions properly, and is only designed to be used when you are unable to configure your application to handle SQLExceptions resulting from dead and stale connections properly. Alternatively, investigate setting the MySQL server variable "wait_timeout" to some high value rather than the default of 8 hours.

이런 설명이 나온다... 

서버 옵션에 대한 설명은 아래에 있다.

http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html

MySQL 5.1 의 경우 설치 디렉토리 아래의 my.ini 파일을 수정해주면 된다.

#연결 시간 timeout 설정
wait_timeout=100000000
interactive_timeout=00000000


위와 같은 항목을 추가해준다.

wait_timeout 과 interactive_timeout 의 차이는 잘 모르겠다


설정 후 mysql 서비스를 재시작한다 (윈도우의 경우)

▶ 윈도우
[제어판] - [관리도구] - [서비스] - MySQL 서비스 다시 시작 ( 컨텍스트 메뉴 )
  
▶ 리눅스
$etc/initd/mysql/mysql restart 

'DB' 카테고리의 다른 글

Mysql에서 한글이 깨질 때  (0) 2012.03.17
Mysql 대소문자 구분해서 쿼리하기  (0) 2012.03.17
Mysql 한글검색  (0) 2012.03.17
Mysql 에서 foreign key 설정  (0) 2012.03.17
Posted by 휘사마
,