Hibernate/JPA/Spring
455800Jun 1 2007 — edited May 7 2008Dear Forum
I want to use TimesTen via Spring (V2)/JPA/Hibernate (V3.2) on a Windows XP SP2 machine with Java 1.5. Using the client-server-connection works though the name gets verified in the other direction: it is ten times more slowly than any “normal” DB (Hsqldb, mysql, oracle).
I wanted to try also the direct connection which works to some extent when using plain JDBC and TimesTenDataSource (to add username and password) but time to connect was about 5 seconds!
When using Hibernate (via JPA) obviously the connection request gets timed out (about 30 seconds) and I got com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source (Full stacktrace below).
Here my persistency configuration:
<property name="hibernate.connection.driver_class"
value="com.timesten.jdbc.TimesTenDriver"/>
<property name="hibernate.connection.url"
value="jdbc:timesten:direct:TROMAN-TT"></property>
<property name="hibernate.dialect"
value="org.hibernate.dialect.TimesTenDialect"/>
<property name="hibernate.connection.username"
value="medl"/>
<property name="hibernate.connection.password"
value="xxxxxx"/>
Using instead a server client connection with the following configuration works but about 10 times more slowly:
<property name="hibernate.connection.driver_class"
value="com.timesten.jdbc.TimesTenClientDriver"/>
<property name="hibernate.connection.url"
value="jdbc:timesten:client:TROMANCS-TT"></property>
<property name="hibernate.dialect"
value="org.hibernate.dialect.TimesTenDialect"/>
<property name="hibernate.connection.username"
value="medl"/>
<property name="hibernate.connection.password"
value="xxxxxx"/>
Here the complete stack trace:
Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Cannot
open connection
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:630)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:75)
at at.siemens.pse.roman.solver.server.ims.dao.TrainDAOPlainJPAImpl.getTrainsPassingLocation(TrainDAOPlainJPAImpl.java:1
91)
at at.siemens.pse.roman.solver.server.ims.service.SimpleDataService.getTrainsPassingLocation(SimpleDataService.java:452
)
at at.siemens.pse.roman.solver.server.importService.SimpleImportService.queryTrainByLocation(SimpleImportService.java:3
52)
at at.siemens.pse.roman.solver.server.importService.SimpleImportService.main(SimpleImportService.java:464)
Caused by: 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:426)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547)
at org.hibernate.loader.Loader.doQuery(Loader.java:673)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2220)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:66)
... 4 more
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:56)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
... 17 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)
... 20 more
Wolfgang Medlitsch