请问一下 用Spring Hibernate连数据库怎么会突然中断呢 数据据用的是MySql问题是这种的, 当突然频繁刷新页面的时候, 会导致崩溃, 报错如下:严重: >>org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: Cannot open connection; uncategorized SQLException for SQL [???]; SQL state [null]; error code [0]; Cannot create PoolableConnectionFactory (Data source rejected establishment of connection, message from server: "Too many connections"); nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Data source rejected establishment of connection, message from server: "Too many connections")
>>org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Data source rejected establishment of connection, message from server: "Too many connections")
[SQL: 1040, 08004]
我目前是在一台机器上一个人测试的,怎么会崩溃掉呢是数据库的问题, 还是Hibernate的问题, 还是Spring的问题呢?谢谢!
目前只是按照最基本的配置做的, 而且是用 spring整合了hibernater 配置,不知道配置哪里需要改, 还是在hibernate里 不是 已经有if(conn!=null){conn.close;} 了吗 那么spring整合它,应该不需要再配吧,<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:///test</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value>root</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>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>net/kk/domain/User.hbm.xml</value>
</list>
</property>
</bean> <bean id="userDAO" class="net.kk.dao.impl.UserDAOImpl">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
</beans>