-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: GenericJDBCException: Cannot open connection
PostPosted: Tue Jan 25, 2011 6:21 am 
Newbie

Joined: Tue Jan 25, 2011 6:07 am
Posts: 2
Hi

I am new to hibernate. I am trying to delpoy an Application called Endeavour-Agile that requires a Java enabled web server. So I installed Tomcat 7.0.6 and I am using Microsoft SQL Server. Now, when I try to start the application, I get a few exceptions.

The hiberante.cfg file is here:

<hibernate-configuration>
<session-factory>

<property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property name="hibernate.connection.url">jdbc:sqlserver://localhost:1433;DatabaseName=endeavour</property>
<property name="hibernate.connection.username">webadmin</property>
<property name="hibernate.connection.password">w@b@dmin456</property>

<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">80</property>
<property name="hibernate.c3p0.timeout">3000</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="hibernate.connection.release_mode">auto</property>

<!-- SQL to stdout logging
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="use_sql_comments">true</property>
-->

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

<mapping resource="org/endeavour/mgmt/model/ProjectMember.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/Project.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/Iteration.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/WorkProduct.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/TestCase.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/TestPlan.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/TestRun.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/Document.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/Version.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/Defect.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/Task.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/Dependency.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/ChangeRequest.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/UseCase.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/Actor.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/Event.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/Attachment.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/Comment.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/GlossaryTerm.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/SecurityGroup.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/Privilege.hbm.xml"/>

</session-factory>
</hibernate-configuration>


And the stack trace is as follows:

org.hibernate.exception.GenericJDBCException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:449)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:142)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:85)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1353)
at org.endeavour.mgmt.model.persistence.PersistenceManager.beginTransaction(PersistenceManager.java:54)
at org.endeavour.mgmt.controller.ApplicationController.startUnitOfWork(ApplicationController.java:45)
at org.endeavour.mgmt.view.LoginView.login(LoginView.java:132)
at org.endeavour.mgmt.view.LoginView.actionPerformed(LoginView.java:126)
at thinwire.ui.EventListenerImpl.fireEvent(EventListenerImpl.java:313)
at thinwire.ui.EventListenerImpl.fireAction(EventListenerImpl.java:245)
at thinwire.ui.AbstractComponent.fireAction(AbstractComponent.java:158)
at thinwire.ui.Button.fireAction(Button.java:82)
at thinwire.render.web.ComponentRenderer.componentChange(ComponentRenderer.java:375)
at thinwire.render.web.EventProcessor.processUserActionEvent(EventProcessor.java:129)
at thinwire.render.web.EventProcessor.run(EventProcessor.java:85)
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)
... 15 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)
... 18 more
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)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:142)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:85)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1353)
at org.endeavour.mgmt.model.persistence.PersistenceManager.beginTransaction(PersistenceManager.java:54)
at org.endeavour.mgmt.controller.ApplicationController.startUnitOfWork(ApplicationController.java:45)
at org.endeavour.mgmt.view.LoginView.login(LoginView.java:132)
at org.endeavour.mgmt.view.LoginView.actionPerformed(LoginView.java:126)
at thinwire.ui.EventListenerImpl.fireEvent(EventListenerImpl.java:313)
at thinwire.ui.EventListenerImpl.fireAction(EventListenerImpl.java:245)
at thinwire.ui.AbstractComponent.fireAction(AbstractComponent.java:158)
at thinwire.ui.Button.fireAction(Button.java:82)
at thinwire.render.web.ComponentRenderer.componentChange(ComponentRenderer.java:375)
at thinwire.render.web.EventProcessor.processUserActionEvent(EventProcessor.java:129)
at thinwire.render.web.EventProcessor.run(EventProcessor.java:85)
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)
... 18 more
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)
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)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:142)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:85)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1353)
at org.endeavour.mgmt.model.persistence.PersistenceManager.beginTransaction(PersistenceManager.java:54)
at org.endeavour.mgmt.controller.ApplicationController.startUnitOfWork(ApplicationController.java:45)
at org.endeavour.mgmt.view.LoginView.login(LoginView.java:132)
at org.endeavour.mgmt.view.LoginView.actionPerformed(LoginView.java:126)
at thinwire.ui.EventListenerImpl.fireEvent(EventListenerImpl.java:313)
at thinwire.ui.EventListenerImpl.fireAction(EventListenerImpl.java:245)
at thinwire.ui.AbstractComponent.fireAction(AbstractComponent.java:158)
at thinwire.ui.Button.fireAction(Button.java:82)
at thinwire.render.web.ComponentRenderer.componentChange(ComponentRenderer.java:375)
at thinwire.render.web.EventProcessor.processUserActionEvent(EventProcessor.java:129)
at thinwire.render.web.EventProcessor.run(EventProcessor.java:85)


I've tried changing the release mode and the c3p0 max and min size but none of these seem to work. Any help would be highly appreciated !


Top
 Profile  
 
 Post subject: Re: GenericJDBCException: Cannot open connection
PostPosted: Tue Jan 25, 2011 10:13 am 
Newbie

Joined: Tue Jan 25, 2011 6:07 am
Posts: 2
The problem was solved. It was just a MSSQL username/password conflict.


Top
 Profile  
 
 Post subject: Re: GenericJDBCException: Cannot open connection
PostPosted: Mon Mar 04, 2013 3:19 am 
Newbie

Joined: Thu Feb 28, 2013 2:57 am
Posts: 2
I am also facing the same issue.


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.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:70)
at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:278)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:297)
... 15 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)

How ever there is no issue with user name and password.

here is the application-context file.

the jdbc.properties file provides the commection related details
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

<context:property-placeholder location="classpath:jdbc.properties"/>

<!-- Connection Pool -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${jdbc.driverClass}"/>
<property name="jdbcUrl" value="${jdbc.url}"/>
<property name="user" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<property name="idleConnectionTestPeriod" value="10800"/>
<property name="maxIdleTime" value="21600"/>

</bean>
<!--
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass" value="${jdbc.driverClass}"/>
<property name="jdbcUrl" value="${jdbc.url}"/>
<property name="properties">
<props>
<prop key="c3p0.minPoolSize">0</prop>
<prop key="hc3p0.maxPoolSize">1000</prop>
<prop key="hc3p0.timeout">3000</prop>
<prop key="c3p0.acquire_increment">10</prop>
<prop key="c3p0.max_statement">50</prop>

<prop key="hibernate.c3p0.idle_test_period">60</prop>

<prop key="hibernate.c3p0.testConnectionOnCheckout">false</prop>
<prop key="user">${jdbc.username}</prop>
<prop key="password">${jdbc.password}</prop>
</props>
</property>
</bean>
-->

<!-- JPA EntityManagerFactory -->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
p:dataSource-ref="dataSource">
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="database" value="${jdbc.database}"/>
<property name="showSql" value="${jdbc.showSql}"/>

</bean>
</property>
</bean>

<!-- Transaction manager for a single JPA EntityManagerFactory (alternative to JTA) -->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="entityManagerFactory"/>

<!-- Activates various annotations to be detected in bean classes for eg @Autowired-->
<context:annotation-config/>

<!-- enable the configuration of transactional behavior based on annotations -->
<tx:annotation-driven transaction-manager="transactionManager"/>



<!-- Property Configurator -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:jdbc.properties"/>
</bean>

<context:component-scan base-package="com.test.dao"/>

<bean id="contactService" class="com.test.service.ContactServiceImpl"/>

</beans>



the database i am using is hsqldb

Can somebody please help me on that.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.