Question

this is my hibernate.cfg.xml

<session-factory>
  <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
  <property name="hibernate.connection.url">jdbc:mysql://192.168.0.23:3306/meili_s?useUnicode=true&amp;characterEncoding=UTF-8</property>
  <property name="hibernate.connection.username">root</property>
  <property name="hibernate.connection.password">password</property>


    <property name="show_sql">false</property>
    <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
    <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

    <property name="hibernate.c3p0.min_size">5</property>
    <property name="hibernate.c3p0.max_size">50</property>
    <property name="hibernate.c3p0.maxStatementsPerConnection">30</property>

    <property name="hibernate.c3p0.timeout">3600</property>  <!-- seconds -->
    <property name="hibernate.c3p0.idle_test_period">300</property> <!-- seconds -->
    <property name="hibernate.c3p0.testConnectionOnCheckin">true</property>
    <property name="hibernate.c3p0.preferredTestQuery">select 1;</property>

    <property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>

The problem is that when the "hibernate.connection.url" has the IP address (of my VM) like just "localhost" all works but when it is an IP number (except for 127.0.0.1) i get this error:

Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:529)
at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128)
at org.hibernate.connection.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:78)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
... 45 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:1319) at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557) at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:477) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:525) ... 48 more

have you ever had some issue?

thanks lot in advance.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top