,
Я пытаюсь использовать docker mysql с hibernate-приложением.мои свойства db.properties:
hibernate.connection.username=root
hibernate.connection.password=pass
hibernate.hbm2ddl.auto=update
hibernate.connection.url=jdbc:mysql://172.17.0.2:3306/keystone?autoReconnect=true
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
, где используется ip контейнера Docker (172.17.0.2) .
моя конфигурация гибернации:
<property name="show_sql">false</property>
<property name="format_sql">true</property>
<property name="use_sql_comments">false</property>
<property name="generate_statistics">false</property>
<property name="max_fetch_depth">2</property>
<property name="default_batch_fetch_size">16</property>
<property name="use_streams_for_binary">true</property>
<property name="connection.isolation">2</property>
<property name="hibernate.transaction.flush_before_completion">true</property>
<property name="hibernate.temp.use_jdbc_metadata_defaults">false</property>
<property name="hibernate.c3p0.min_size">2</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">300</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<property name="hibernate.cache.use_structured_entries">true</property>
<property name="hibernate.cache.use_query_cache">true</property>
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property>
</session-factory>
Я могу получить доступ к Docker MySQL с любого клиента , но когда я пытаюсь подключиться из своего приложения, я получаю эту ошибку:
<exception name="Could not open connection">
org.hibernate.exception.GenericJDBCException: Could not open connection
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:221)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.getConnection(LogicalConnectionImpl.java:157)
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doBegin(JdbcTransaction.java:67)
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:160)
at org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1426)
at org.jpos.ee.DB.beginTransaction(DB.java:168)
at com.bkash.keystone.participant.AbstractParticipant.openDB(AbstractParticipant.java:91)
at com.bkash.keystone.participant.AbstractParticipant.createTrace(AbstractParticipant.java:150)
at com.bkash.keystone.participant.AbstractParticipant.traceDb(AbstractParticipant.java:144)
at com.bkash.keystone.participant.AbstractParticipant.log(AbstractParticipant.java:124)
at com.bkash.keystone.participant.AbstractParticipant.prepare(AbstractParticipant.java:68)
at org.jpos.transaction.TransactionManager.prepare(TransactionManager.java:571)
at org.jpos.transaction.TransactionManager.prepare(TransactionManager.java:637)
at org.jpos.transaction.TransactionManager.run(TransactionManager.java:308)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:118)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:689)
at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:140)
at org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:84)
at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:292)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:214)
... 14 more
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1418)
at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:606)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:526)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutAndMarkConnectionInUse(C3P0PooledConnectionPool.java:755)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:682)
... 18 more
</exception>
Hibernate не смог получить соединение из пула соединений mysql.Не знаю почему.
Кто-нибудь может помочь?