| Author |
Problems to connect to mysql with hibernate
|
Fabio Batalha
Greenhorn
Joined: Aug 11, 2004
Posts: 6
|
|
Please, someone cold help me with this problem? I�m having problems to connect to my database using hibernate. This is the problem: Exception in thread "main" org.hibernate.exception.GenericJDBCException: Cannot open connection at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103) at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29) at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:420) at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144) at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:129) at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57) at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1290) at org.bireme.scieloorgupdate.Teste.main(Teste.java:24) Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database! at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:104) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:236) at com.mchange.v2.c3p0.PoolBackedDataSource.getConnection(PoolBackedDataSource.java:94) at org.hibernate.connection.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:35) at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:417) ... 5 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.awaitAcquire(BasicResourcePool.java:970) at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:208) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:232) ... 8 more This is my hibernate.cfg.xml <!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.dialect"> org.hibernate.dialect.MySQLDialect </property> <property name="hibernate.connection.driver_class"> com.mysql.jdbc.Driver </property> <property name="hibernate.connection.url"> jdbc:mysql://jade.bireme.br/hibernate?autoReconnect=true </property> <property name="hibernate.connection.username"> scielo </property> <property name="hibernate.connection.password"> scielo </property> <!-- Condigura��o do c3p0 --> <property name="hibernate.c3p0.max_size">10</property> <property name="hibernate.c3p0.min_size">2</property> <property name="hibernate.c3p0.timeout">5000</property> <property name="hibernate.c3p0.max_statements">10</property> <property name="hibernate.c3p0.idle_test_period">3000</property> <property name="hibernate.c3p0.acquire_increment">2</property> <!-- Configura��es de debug --> <property name="show_sql">true</property> <property name="hibernate.generate_statistics">true</property> <property name="hibernate.use_sql_comments">true</property> <mapping resource="profiles.hbm.xml"/> <mapping resource="articles.hbm.xml"/> <mapping resource="profile_article.hbm.xml"/> </session-factory> </hibernate-configuration> Fabio Batalha
|
 |
Fabio Batalha
Greenhorn
Joined: Aug 11, 2004
Posts: 6
|
|
Tks everybody I already solve the problem the hibernate.connection.url was wrong!
|
 |
kamal raja
Greenhorn
Joined: May 10, 2009
Posts: 2
|
|
I got the same exception & resolved the issue after 3 hectic days.Check if you are using I hibernate3. In this version it is req to explicitly mention the connection class name. Also check if the jar is in classpath. Check steps & comments in below link
http://hibernatedb.blogspot.com/2009/05/automatic-reconnect-from-hibernate-to.html
Remove autoReconnec=true
|
 |
 |
|
|
subject: Problems to connect to mysql with hibernate
|
|
|