0

Hibernate を使用して MySQL DB に接続する Java アプリケーションを開発しました。Mac OS X を使用するとアプリは正常に動作しますが、Windows (XP) で使用しようとすると、次のエラーが発生します。

    Exception in thread "main" 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:304)
    at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.getConnection(LogicalConnectionImpl.java:169)
    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:1395)
    at persistence.Axdbv4HibernateManager.getNRecords(Axdbv4HibernateManager.java:51)
    at manager.Phase1.startPhase1(Phase1.java:28)
    at manager.Phase1.main(Phase1.java:89)
    at manager.Main.main(Main.java:60)
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:677)
    at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128)
    at org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:79)
    at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:292)
    at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:297)
    ... 8 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:1406)
    at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:594)
    at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:514)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutAndMarkConnectionInUse(C3P0PooledConnectionPool.java:743)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:670)
    ... 12 more

これは私の休止状態の構成ファイルです

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC"-//Hibernate/Hibernate Configuration DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

<session-factory>

<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>

<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>

<property name="hibernate.connection.url">jdbc:mysql://localhost/axdbv4</property>

<property name="hibernate.connection.username">root</property>

<property name="hibernate.connection.password">mypassword</property> 

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

<property name="hibernate.c3p0.min_size">1</property> 

<property name="hibernate.c3p0.max_size">300</property>

<property name="hibernate.c3p0.timeout">30</property> 

<property name="hibernate.c3p0.max_statements">50</property> 

<property name="hibernate.c3p0.idle_test_period">100</property>

<property name="hibernate.c3p0.maxPoolSize">100</property>

<property name="hibernate.c3p0.minPoolSize">5</property>

<mapping resource="domain/DcmiRecord.hbm.xml" />

<mapping resource="domain/OccurrenceNameRecord.hbm.xml" />

<mapping resource="domain/OptionalFieldRecord.hbm.xml" />

<mapping resource="domain/RepresentationsNamesRecord.hbm.xml" />

<mapping resource="domain/NIDInfoRecord.hbm.xml" />

</session-factory>

</hibernate-configuration>

私はすでに使用してデータベースに接続しようとしました

mysql -u root -h localhost -p mypassword

そしてそれはうまくいきます。誰もそれを処理する方法を知っていますか? ありがとう!

4

1 に答える 1