Announcement Announcement Module
Collapse
No announcement yet.
spring + hibernate + c3p0 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring + hibernate + c3p0

    When i use this:

    <bean id="mmpDataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
    <property name="driverClassName"> <value>${db.connection.driver_class}</value> </property>
    <property name="url"> <value>${db.connection.url}</value> </property>
    <property name="username"> <value>${db.connection.username}</value> </property>
    <property name="password"> <value>${db.connection.password}</value> </property>
    </bean>

    it works

    but when i use this

    <bean id="mmpDataSource"
    class="com.mchange.v2.c3p0.ComboPooledDataSource">
    <!--<property name="driverClassName">-->
    <property name="driverClass"><value>${db.connection.driver_c lass}</value></property>
    <property name="jdbcUrl"><value>${db.connection.url}</value></property>
    <property name="user"><value>${db.connection.username}</value></property>
    <property name="password"><value>${db.connection.password}</value>
    </property>
    </bean>

    i get the following stack trace:


    [ 2009-05-27 19:19:42,460 ] [ DEBUG ] [ org.springframework.orm.hibernate3.HibernateTransa ctionManager ] - Creating new transaction with name [testInsert]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
    [ 2009-05-27 19:19:42,488 ] [ DEBUG ] [ org.springframework.orm.hibernate3.HibernateTransa ctionManager ] - Opened new Session [org.hibernate.impl.SessionImpl@1f39c59] for Hibernate transaction
    [ 2009-05-27 19:19:42,490 ] [ DEBUG ] [ org.springframework.orm.hibernate3.HibernateTransa ctionManager ] - Preparing JDBC Connection of Hibernate Session [org.hibernate.impl.SessionImpl@1f39c59]
    [ 2009-05-27 19:19:58,567 ] [ ERROR ] [ org.hibernate.util.JDBCExceptionReporter ] - Connections could not be acquired from the underlying database!
    [ 2009-05-27 19:19:58,569 ] [ ERROR ] [ org.hibernate.util.JDBCExceptionReporter ] - Connections could not be acquired from the underlying database!
    [ 2009-05-27 19:19:58,571 ] [ DEBUG ] [ org.springframework.orm.hibernate3.SessionFactoryU tils ] - Closing Hibernate Session
    [ 2009-05-27 19:19:58,573 ] [ WARN ] [ org.springframework.test.context.TestContextManage r ] - Caught exception while allowing TestExecutionListener [org.springframework.test.context.transaction.Trans actionalTestExecutionListener@6c570c] to process 'before' execution of test method [public void com.mobispine.mmp.persistence.dao.CustomerPersiste nceTest.testInsert()] for test instance [null(com.mobispine.mmp.persistence.dao.CustomerPer sistenceTest)]
    org.springframework.transaction.CannotCreateTransa ctionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Cannot open connection
    at org.springframework.orm.hibernate3.HibernateTransa ctionManager.doBegin(HibernateTransactionManager.j ava:599)
    at org.springframework.transaction.support.AbstractPl atformTransactionManager.getTransaction(AbstractPl atformTransactionManager.java:377)
    at org.springframework.test.context.transaction.Trans actionalTestExecutionListener$TransactionContext.s tartTransaction(TransactionalTestExecutionListener .java:496)
    at org.springframework.test.context.transaction.Trans actionalTestExecutionListener.startNewTransaction( TransactionalTestExecutionListener.java:256)
    at org.springframework.test.context.transaction.Trans actionalTestExecutionListener.beforeTestMethod(Tra nsactionalTestExecutionListener.java:149)
    at org.springframework.test.context.TestContextManage r.beforeTestMethod(TestContextManager.java:292)
    at org.springframework.test.context.junit4.SpringMeth odRoadie.runBefores(SpringMethodRoadie.java:270)
    at org.springframework.test.context.junit4.SpringMeth odRoadie$RunBeforesThenTestThenAfters.run(SpringMe thodRoadie.java:332)
    at org.springframework.test.context.junit4.SpringMeth odRoadie.runWithRepetitions(SpringMethodRoadie.jav a:217)
    at org.springframework.test.context.junit4.SpringMeth odRoadie.runTest(SpringMethodRoadie.java:197)
    at org.springframework.test.context.junit4.SpringMeth odRoadie.run(SpringMethodRoadie.java:143)
    at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.invokeTestMethod(SpringJUnit4ClassRu nner.java:142)
    at org.junit.internal.runners.JUnit4ClassRunner.runMe thods(JUnit4ClassRunner.java:51)
    at org.junit.internal.runners.JUnit4ClassRunner$1.run (JUnit4ClassRunner.java:44)
    at org.junit.internal.runners.ClassRoadie.runUnprotec ted(ClassRoadie.java:27)
    at org.junit.internal.runners.ClassRoadie.runProtecte d(ClassRoadie.java:37)
    at org.junit.internal.runners.JUnit4ClassRunner.run(J Unit4ClassRunner.java:42)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestR eference.run(JUnit4TestReference.java:45)
    at org.eclipse.jdt.internal.junit.runner.TestExecutio n.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:460)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:673)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:386)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:196)
    Caused by: org.hibernate.exception.GenericJDBCException: Cannot open connection
    at org.hibernate.exception.SQLStateConverter.handledN onSpecificException(SQLStateConverter.java:103)
    at org.hibernate.exception.SQLStateConverter.convert( SQLStateConverter.java:91)
    at org.hibernate.exception.JDBCExceptionHelper.conver t(JDBCExceptionHelper.java:43)
    at org.hibernate.exception.JDBCExceptionHelper.conver t(JDBCExceptionHelper.java:29)
    at org.hibernate.jdbc.ConnectionManager.openConnectio n(ConnectionManager.java:426)
    at org.hibernate.jdbc.ConnectionManager.getConnection (ConnectionManager.java:144)
    at org.hibernate.jdbc.JDBCContext.connection(JDBCCont ext.java:119)
    at org.hibernate.transaction.JDBCTransaction.begin(JD BCTransaction.java:84)
    at org.hibernate.impl.SessionImpl.beginTransaction(Se ssionImpl.java:1330)
    at org.springframework.orm.hibernate3.HibernateTransa ctionManager.doBegin(HibernateTransactionManager.j ava:558)
    ... 22 more
    Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
    at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtil s.java:106)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool. checkoutPooledConnection(C3P0PooledConnectionPool. java:529)
    at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSou rce.getConnection(AbstractPoolBackedDataSource.jav a:128)
    at org.springframework.orm.hibernate3.LocalDataSource ConnectionProvider.getConnection(LocalDataSourceCo nnectionProvider.java:82)
    at org.hibernate.jdbc.ConnectionManager.openConnectio n(ConnectionManager.java:423)
    ... 27 more
    Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceE xception: A ResourcePool could not acquire a resource from its primary factory or source.
    at com.mchange.v2.resourcepool.BasicResourcePool.awai tAvailable(BasicResourcePool.java:1319)
    at com.mchange.v2.resourcepool.BasicResourcePool.prel imCheckoutResource(BasicResourcePool.java:557)
    at com.mchange.v2.resourcepool.BasicResourcePool.chec koutResource(BasicResourcePool.java:477)
    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool. checkoutPooledConnection(C3P0PooledConnectionPool. java:525)
    ... 30 more


    Any idea why ?

  • #2
    I'm not in front of a system that I can try things out on at the moment, but you might want to check that you have specified all of the required properties as mentioned in the c3p0 documentation on Hibernate config:

    http://www.mchange.com/projects/c3p0...rnate-specific

    Hope that helps.

    --
    Stephen

    Comment

    Working...
    X