찾다

mysql 连接超时异常

Jun 07, 2016 pm 04:23 PM
mysql이상타임아웃연결하다실수

mysql 连接超时错误 自己的小网站在测试机器上长时间不访问后(默认8小时过期),再次访问发现有如下错误: Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received fro m the server was 63,020,509 m

mysql 连接超时错误

自己的小网站在测试机器上长时间不访问后(默认8小时过期),再次访问发现有如下错误:

Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received fro

m the server was 63,020,509 milliseconds ago. ?The last packet sent successfully to the server was 63,020,509

?milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either e

xpiring and/or testing connection validity before use in your application, increasing the server configured v

alues for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this pr

oblem.

? ? ? ? at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

? ? ? ? at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)

? ? ? ? at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:4

5)

? ? ? ? at java.lang.reflect.Constructor.newInstance(Constructor.java:526)

? ? ? ? at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)

? ? ? ? at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)

? ? ? ? at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3851)

? ? ? ? at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2471)

? ? ? ? at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651)

? ? ? ? at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2683)

? ? ? ? at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2144)

? ? ? ? at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1379)

? ? ? ? at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)

? ? ? ? at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)

?

Fix:?If only the connection pool could check if the the connection it is about to return is live or not, the porblem is fixed. This can be done in apache-common-dbcp (I know this one coz I used it, please look into documentation of the connection-pool you are using). Here’s how you do it: You add the following properties to dbcp configuration.

  • validationQuery=”SELECT 1″
  • testOnBorrow=”true”

And that does the trick.

?

暂时我对我的mysql连接加上: 试试效果

validationQuery="SELECT 1"

?testOnBorrow="true"

?

目前我不想添加: ?autoReconnect=true? 因为我对此的理解不深,mysql文档这样写的:

?

This parameter is?false?by default. This forces disconnected API nodes (including MySQL Servers acting as SQL nodes) to use a new connection to the cluster rather than attempting to re-use an existing one, as re-use of connections can cause problems when using dynamically-allocated node IDs. (Bug #45921)

如果有问题再添加 autoReconnect选项

like this:

?

? ? ? ? ? ? ? ?initialSize="10" maxActive="100" maxIdle="30" maxWait="10000"

? ? ? ? ? ? ? ?username="***" password="***" driverClassName="com.mysql.jdbc.Driver"

? ? ? ? ? ? ? ?url="jdbc:mysql://localhost:3306/saasNetTest"

? ? ? ? ? ? ? ?validationQuery="SELECT 1"

? ? ? ? ? ? ? ?testOnBorrow="true"

?

? ? />

?

参考文档:http://stackoverflow.com/questions/9674165/mysql-jdbc-timeout-even-with-autoreconnect-true

http://amitcodes.com/2008/07/26/16/

http://www.tomcatexpert.com/blog/2010/04/01/configuring-jdbc-pool-high-concurrency

?

성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
MySQL의 Blob Data Type : 개발자를위한 상세한 개요MySQL의 Blob Data Type : 개발자를위한 상세한 개요May 07, 2025 pm 05:41 PM

blobdatatypesinmysqlareusedforvoringlargebinarydatalikeimagesoraudio.1) useblobtypes (tinyblobtolongblob) 기반 론다 타지 세인. 2) StoreBlobsin perplate petooptimize 성능.

명령 줄에서 MySQL에 사용자를 추가하는 방법명령 줄에서 MySQL에 사용자를 추가하는 방법May 07, 2025 pm 05:01 PM

toadduserstomysqlfromthecommandline, loginasroot, whenUseCreateUser'Username '@'host'IdentifiedBy'Password '; toCreateAwUser.grantPerMissionswithGrantAllilegesOndatabase

MySQL의 다른 문자열 데이터 유형은 무엇입니까? 자세한 개요MySQL의 다른 문자열 데이터 유형은 무엇입니까? 자세한 개요May 07, 2025 pm 03:33 PM

mysqlofferSeightStringDatatatypes : char, varchar, binary, varbinary, blob, text, enum and set.1) charisfix-length, 2) varcharisvariable-length, 효율적 인 datalikenames.3) binaryandvarbinary-binary Binary Binary Binary Binary Binary Binary Binary-Binary

MySQL에서 사용자 추가에 대한 궁극적 인 안내서MySQL에서 사용자 추가에 대한 궁극적 인 안내서May 07, 2025 pm 03:29 PM

Toaddauserinmysql, usethecreateuserstatement.1) usecreateuser'newuser '@'localhost'Identifiedby'Password '; 2) enforcestongpasspoliciesswithvalidate_passwordpluginsettings

MySQL에 저장된 절차는 무엇입니까?MySQL에 저장된 절차는 무엇입니까?May 01, 2025 am 12:27 AM

저장된 절차는 성능을 향상시키고 복잡한 작업을 단순화하기 위해 MySQL에서 사전 컴파일 된 SQL 문입니다. 1. 성능 향상 : 첫 번째 편집 후 후속 통화를 다시 컴파일 할 필요가 없습니다. 2. 보안 향상 : 권한 제어를 통해 데이터 테이블 액세스를 제한합니다. 3. 복잡한 작업 단순화 : 여러 SQL 문을 결합하여 응용 프로그램 계층 로직을 단순화합니다.

쿼리 캐싱은 MySQL에서 어떻게 작동합니까?쿼리 캐싱은 MySQL에서 어떻게 작동합니까?May 01, 2025 am 12:26 AM

MySQL 쿼리 캐시의 작동 원리는 선택 쿼리 결과를 저장하는 것이며 동일한 쿼리가 다시 실행되면 캐시 된 결과가 직접 반환됩니다. 1) 쿼리 캐시는 데이터베이스 읽기 성능을 향상시키고 해시 값을 통해 캐시 된 결과를 찾습니다. 2) MySQL 구성 파일에서 간단한 구성, query_cache_type 및 query_cache_size를 설정합니다. 3) SQL_NO_CACHE 키워드를 사용하여 특정 쿼리의 캐시를 비활성화하십시오. 4) 고주파 업데이트 환경에서 쿼리 캐시는 성능 병목 현상을 유발할 수 있으며 매개 변수의 모니터링 및 조정을 통해 사용하기 위해 최적화해야합니다.

다른 관계형 데이터베이스를 통해 MySQL을 사용하면 어떤 장점이 있습니까?다른 관계형 데이터베이스를 통해 MySQL을 사용하면 어떤 장점이 있습니까?May 01, 2025 am 12:18 AM

MySQL이 다양한 프로젝트에서 널리 사용되는 이유에는 다음이 포함됩니다. 1. 고성능 및 확장 성, 여러 스토리지 엔진을 지원합니다. 2. 사용 및 유지 관리, 간단한 구성 및 풍부한 도구; 3. 많은 지역 사회 및 타사 도구 지원을 유치하는 풍부한 생태계; 4. 여러 운영 체제에 적합한 크로스 플랫폼 지원.

MySQL에서 데이터베이스 업그레이드를 어떻게 처리합니까?MySQL에서 데이터베이스 업그레이드를 어떻게 처리합니까?Apr 30, 2025 am 12:28 AM

MySQL 데이터베이스를 업그레이드하는 단계에는 다음이 포함됩니다. 1. 데이터베이스 백업, 2. 현재 MySQL 서비스 중지, 3. 새 버전의 MySQL 설치, 4. 새 버전의 MySQL 서비스 시작, 5. 데이터베이스 복구. 업그레이드 프로세스 중에 호환성 문제가 필요하며 Perconatoolkit과 같은 고급 도구를 테스트 및 최적화에 사용할 수 있습니다.

See all articles

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

Video Face Swap

Video Face Swap

완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

뜨거운 도구

에디트플러스 중국어 크랙 버전

에디트플러스 중국어 크랙 버전

작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음

WebStorm Mac 버전

WebStorm Mac 버전

유용한 JavaScript 개발 도구

DVWA

DVWA

DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는

mPDF

mPDF

mPDF는 UTF-8로 인코딩된 HTML에서 PDF 파일을 생성할 수 있는 PHP 라이브러리입니다. 원저자인 Ian Back은 자신의 웹 사이트에서 "즉시" PDF 파일을 출력하고 다양한 언어를 처리하기 위해 mPDF를 작성했습니다. HTML2FPDF와 같은 원본 스크립트보다 유니코드 글꼴을 사용할 때 속도가 느리고 더 큰 파일을 생성하지만 CSS 스타일 등을 지원하고 많은 개선 사항이 있습니다. RTL(아랍어, 히브리어), CJK(중국어, 일본어, 한국어)를 포함한 거의 모든 언어를 지원합니다. 중첩된 블록 수준 요소(예: P, DIV)를 지원합니다.

Atom Editor Mac 버전 다운로드

Atom Editor Mac 버전 다운로드

가장 인기 있는 오픈 소스 편집기