Hello,
For the moment I'm developing a webshop, the architecture is based on Spring - Hibernate - Struts & Mysql. After ... minutes I get an "explosion" of open databaseconnection. I tried the c3p0 connection pool also but that gives the same problems (crasch of application after several minutes). I got the best result with following configuration : (but still connection explosion).
jdbc.properties file hibernate.dialect org.hibernate.dialect.MySQLDialect hibernate.connection.driver_class com.mysql.jdbc.Driver hibernate.connection.url jdbc:mysql://localhost:3306/rdcoshop?autoReconnect=true hibernate.connection.username rdcoshop hibernate.connection.password rdcoshop
jdbc.properties file <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <!-- ========================================================== PROPERTY CONF--> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="classpath:jdbc.properties"/> </bean>
<!-- ========================================================== DATASOURCE --> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="${hibernate.connection.driver_class}"/> <property name="url" value="${hibernate.connection.url}"/> <property name="username" value="${hibernate.connection.username}"/> <property name="password" value="${hibernate.connection.password}"/> </bean>
<!-- ========================================================== HIBERNATE --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"><ref local="dataSource"/></property>
<property name="mappingResources"> <list> <value>Users.hbm.xml</value> </list> </property>
<property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.show_sql">false</prop> <prop key="hibernate.query.substitutions">true 1, false 0, yes 'Y', no 'N'</prop> <prop key="hibernate.max_fetch_depth">1</prop> </props> </property> </bean>
<!-- ========================================================== TRANSACTIONS --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"><ref local="sessionFactory"/></property> </bean>
<bean id="rightDAO" class="db.persistence.RightDAOImpl"> <property name="sessionFactory" ref="sessionFactory"/> </bean>
</beans>
Does anyone know if this is a general problem between spring - hibernate & mysql ? Can anyone give me the ideal setup?
Thanks for your help !!!
|