MySQL과 MySQL Connector/J (MySQL 용 공식 JDBC 드라이버)를 사용하는 Java EE 애플리케이션에서 최대 절전 모드 (3.6.0.-Final)에 문제가 있습니다. 내 hibernate.cfg.xml
에서Hibernate JDBCExceptionReporter -> 연결 유효 기간, 시간 초과, 자동 다시 연결
, 내가 코드 줄이 : 나는 누군가가 나에게 이런 얘기를했다 않았기 때문에 20 일에서 재산 connection.pool_size
의 값을 변경 (나는이 문제를 가지고 있었다)
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/mydbtest</property>
<property name="connection.username">root</property>
<property name="connection.password">mypassword</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">20</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Enable Hibernate's automatic session context management, in this case
the session will be close after each transaction! -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- auto create tables -->
<property name="hbm2ddl.auto">none</property>
...
</session-factory>
</hibernate-configuration>
, 데이터가로드되지 않았으며 연결 풀 크기와 함께 오류가 발생했음을 나타냅니다. 또한,
그래서 나는 20에 값을 변경하지만 지금은이 오류를 얻을 :
Hibernate: select ...
WARN : org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: 08S01
ERROR: org.hibernate.util.JDBCExceptionReporter -
The last packet successfully received from the server was 61.428.729
milliseconds ago. The last packet sent successfully to the server was
61.428. milliseconds ago. is longer than the server configured value of
'wait_timeout'. You should consider either expiring and/or testing
connection validity before use in your application, increasing the server
configured values for client timeouts, or using the Connector/J
connection property 'autoReconnect=true' to avoid this problem.
그래서 난이 가능한 솔루션에 대해 어떻게해야합니까? 이러한 JDBC 연결 문제를 해결하는 가장 좋은 방법은 무엇입니까? c3p0
에 대해 sth를 읽었지만 연결 풀을 처음 사용했습니다. 문제를 이해할 수 없습니다. 연결 풀이 20 개 있습니다. 왜 실패하나요? 예외를 던지고 새 것을 열지 않는 이유는 무엇입니까?
미리 감사드립니다. & 최고 감사합니다.
- 업데이트 -
<property name=“hibernate.c3p0.acquire_increment”>3</property>
<property name=“hibernate.c3p0.idle_test_period”>14400</property>
<property name=“hibernate.c3p0.timeout”>25200</property>
<property name=“hibernate.c3p0.max_size”>15</property>
<property name=“hibernate.c3p0.min_size”>3</property>
<property name=“hibernate.c3p0.max_statements”>0</property>
<property name=“hibernate.c3p0.preferredTestQuery”>select 1;</property>
- 업데이트 2 -
/etc/my.cnf
파일 :
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
문제가 해결 되었습니까? 변경된 사항으로 인해 효과가있었습니다. –