my dog learned polymorphism*
The moose likes Object Relational Mapping and the fly likes Hibernate cannot open connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate cannot open connection" Watch "Hibernate cannot open connection" New topic
Author

Hibernate cannot open connection

Jai babu
Greenhorn

Joined: Oct 29, 2007
Posts: 10
Hai all,

I got an error in my application as shown below.

Error:Cannot open connection.
"org.hibernate.exception.JDBCConnectionException: Cannot open connection"

This will occur if i continuously hit the refresh button in my app. Please, can anyone figure out this issue.

The property file i am using is given below. I make use of the roseindia sample application.

applicationcontext-hibernate.properties

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<!--
- Application context definition for RoseIndia Login Application on Hibernate.
-->
<beans>

<!-- ========================= RESOURCE DEFINITIONS ========================= -->

<!-- Configurer that replaces ${...} placeholders with values from a properties file -->
<!-- (in this case, JDBC-related settings for the dataSource definition below) -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location"><value>/WEB-INF/jdbc.properties</value></property>
</bean>

<!-- Local DataSource that works in any environment -->
<!-- Note that DriverManagerDataSource does not pool; it is not intended for production -->

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName"><value>${jdbc.driverClassName}</value></property>
<property name="url"><value>${jdbc.url}</value></property>
<property name="username"><value>${jdbc.username}</value></property>
<property name="password"><value>${jdbc.password}</value></property>


</bean>


<!-- JNDI DataSource for J2EE environments -->

<!-- Hibernate SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource"><ref local="dataSource"/></property>
<property name="mappingResources">
<list>
<value>roseindia/dao/hibernate/Login.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">true</prop>


</props>


</property>
</bean>


<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>


<!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= -->

<!--
Data access object: Hibernate implementation.
-->

<bean id="HibernateSpringDaoTarget" class="roseindia.dao.SpringHibernateDAOImpl">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>

<!--
- Transactional proxy for Login Application central data access object.
-
- Defines specific transaction attributes with "readOnly" markers,
- which is an optimization that is particularly valuable with Hibernate
- (to suppress unnecessary flush attempts for read-only operations).
-
- Note that in a real-life app with multiple transaction proxies,
- you will probably want to use parent and child bean definitions
- as described in the manual, to reduce duplication.
-->

<bean id="SpringHibernateDao" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager"><ref local="transactionManager"/></property>
<property name="target"><ref local="HibernateSpringDaoTarget"/></property>
<property name="transactionAttributes">
<props>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="store*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>

<!-- Email Service-->
<bean id="mailbean" class="roseindia.web.common.SendMail">
<property name="strSmtp"><value>192.168.10.14</value></property>
</bean>

</beans>


thanks
Jai
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate cannot open connection
 
Similar Threads
Struts Validation in Spring Context
spring 2 with hibernate 3
I am getting org.springframework.orm.hibernate3.HibernateSystemException: Unknown entity:
unsatisfied Dependancy exception
JDBCContext returning TransactionManager as null