当前位置: 代码迷 >> J2EE >> org.springframework.orm.hibernate3.HibernateJdbcException: JDBC exception on Hibernate data access; nested exception is
  详细解决方案

org.springframework.orm.hibernate3.HibernateJdbcException: JDBC exception on Hibernate data access; nested exception is

热度:695   发布时间:2016-04-22 02:16:10.0
spring配置,无法关闭连接,高手帮我看看
报的是这几个错:1,javax.servlet.ServletException: org.springframework.orm.hibernate3.HibernateJdbcException: JDBC exception on Hibernate data access; nested exception is org.hibernate.exception.GenericJDBCException: Cannot open connection,
2,org.springframework.orm.hibernate3.HibernateJdbcException: JDBC exception on Hibernate data access; nested exception is org.hibernate.exception.GenericJDBCException: Cannot open connection
3,org.hibernate.exception.GenericJDBCException: Cannot open connection
4,org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Data source rejected establishment of connection, message from server: "Too many connections")
5,com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Data source rejected establishment of connection, message from server: "Too many connections"

连接总是关闭不了。用着用着就无法连接了。高手帮我看看啊,我怎么找也找不出问题,,类是用extends HibernateDaoSupport的方法写的,用的是getHibernateTemplate()。我实在找不出问题所在,高手帮帮我。以下是我的配置文件。

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

<beans>
<bean id="datasource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property>
<property name="url"><value>jdbc:mysql://localhost:3306/shop</value></property>
<property name="username"><value>root</value></property>
<property name="password"><value>nbsp</value></property>
</bean>


<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource"><ref bean="datasource" /></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>emp/shop/model/User.hbm.xml</value>
<value>emp/shop/model/Orders.hbm.xml</value>
<value>emp/shop/model/PayType.hbm.xml</value>
<value>emp/shop/model/OrderItem.hbm.xml</value>
<value>emp/shop/model/Product.hbm.xml</value>
<value>emp/shop/model/ProductType.hbm.xml</value>
<value>emp/shop/model/SiteHit.hbm.xml</value>
<value>emp/shop/model/Manager.hbm.xml</value>
<value>emp/shop/model/Advice.hbm.xml</value>
</list>
</property>
</bean>


<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>

<!-- ************************以下代码为对用户操作的事务处理*********************** -->

<bean id="userDaoImpl"
class="emp.shop.dao.UserDaoImpl">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>


<bean id="userDaoProxy"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="target">
<ref local="userDaoImpl" />
</property>

<property name="transactionManager">
  相关解决方案