简体   繁体   中英

Java/hibernate - c3p0 Error querying MariaDB

Performing a query on mariaDB with hibernate framework, the system returns the message below:

apr 04, 2019 4:43:48 PM com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource INFORMAZIONI: Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@3a29d5cf [ connectionPoolDataSource -> apr 04, 2019 4:47:58 PM com.mchange.v2.resourcepool.BasicResourcePool ... ... ... AVVERTENZA: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@7a0c574a -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception: java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up. at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63) `

There are no further logs to understand the problem and, overall, it seems that this issue has been occurred suddenly...It is possible that some eclipse updates have changed the previous "good state" of the code? Is there any method to perform a deep debug?

below the hibernate properties file:

hibernate.connection.provider_class=org.hibernate.connection.C3P0ConnectionProvider
hibernate.connection.driver_class=com.mysql.cj.jdbc.Driver
hibernate.connection.url=jdbc:mysql://*******:****/anagraphic?autoReconnect=true&characterEncoding=UTF-8
hibernate.connection.username=*****
hibernate.connection.password=*****
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.show_sql=false
hibernate.use_sql_comments=true
hibernate.format_sql=true
hibernate.generate_statistics=false
hibernate.current_session_context_class=thread
hibernate.jdbc.lob.non_contextual_creation=true

hibernate.connection.autoReconnect=true
hibernate.connection.autoReconnectForPools= true
hibernate.minIdle=5
hibernate.connection.useUnicode=true
hibernate.connection.characterEncoding=UTF-8
hibernate.connection.charSet=UTF-8
hibernate.bytecode.provider = cglib
hibernate.jdbc.use_streams_for_binary =true
hibernate.cglib.use_reflection_optimizer =true
hibernate.jdbc.fetch_size=20
hibernate.jdbc.batch_size=20

hibernate.cache.provider_class=net.sf.ehcache.hibernate.EhCacheProvider
hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
hibernate.cache.user_query_cache=true
hibernate.cache.user_second_level_cache=true

hibernate.c3p0.max_size=15
hibernate.c3p0.min_size=3
hibernate.c3p0.timeout=180
hibernate.c3p0.max_statements=0
hibernate.c3p0.idle_test_period=300
hibernate.c3p0.acquire_increment=3

Solved!! It seems that the problem was caused after the take up of the daylight saving time. The CEST time was the problem; the solution was to add the "serverTimeZone=UTC" to the connection string of maria db...below an example:

jdbc:mysql://*******:****/anagraphic?autoReconnect=true&characterEncoding=UTF-8&serverTimezone=UTC

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM