主题 : 网站第一次打不开,Could not open Hibernate Session for transaction.nested exception is org.hib。刷新一下就打开i了
级别: 贡士
UID: 57390
积分:486 加为好友
威望: 52 精华: 0
主题:67 回复:329
注册时间:2014-01-23
在线时长:0
21#   发表于:2014-01-27 10:53:46  IP:112.132.*.*
好像是30s后断掉,没有重连
级别: 状元
UID: 33380
积分:50625 加为好友
威望: 21 精华: 3
主题:88 回复:30687
注册时间:2012-05-07
在线时长:0
22#   发表于:2014-01-27 11:04:56  IP:111.205.*.*
这个地方值设大一些
功成由勤,业精于勤。
级别: 举人
UID: 45758
积分:164 加为好友
威望: 0 精华: 0
主题:1 回复:142
注册时间:2013-04-02
在线时长:0
23#   发表于:2015-09-10 09:48:10  IP:120.7.*.*
application-context.xml 文件增加两行
<!-- 新增 -->
<property name="idleConnectionTestPeriod" value="120"/>
<!-- 新增 -->
hibernate.autoReconnect=true
位置如下:
cat application-context.xml
<?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:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"
default-lazy-init="true">

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>/WEB-INF/config/jdbc.properties</value>
</list>
</property>
</bean>
<bean id="properties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list>
<value>/WEB-INF/config/jdbc.properties</value>
<value>/WEB-INF/config/jeecms/jeecms.properties</value>
<value>/WEB-INF/config/plug/**/*.properties</value>
</list>
</property>
<qualifier value="main"/>
</bean>
<bean id="propertyUtils" class="com.jeecms.common.util.PropertyUtils">
<property name="properties" ref="properties"/>
</bean>

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${jdbc.driverClassName}" />
<property name="jdbcUrl" value="${jdbc.url}" />
<property name="user" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="autoCommitOnClose" value="true"/>
<property name="checkoutTimeout" value="${cpool.checkoutTimeout}"/>
<property name="initialPoolSize" value="${cpool.minPoolSize}"/>
<property name="minPoolSize" value="${cpool.minPoolSize}"/>
<property name="maxPoolSize" value="${cpool.maxPoolSize}"/>
<property name="maxIdleTime" value="${cpool.maxIdleTime}"/>
<property name="acquireIncrement" value="${cpool.acquireIncrement}"/>
<property name="maxIdleTimeExcessConnections" value="${cpool.maxIdleTimeExcessConnections}"/>
<!-- 新增 -->
<property name="idleConnectionTestPeriod" value="120"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingLocations" value="#{propertyUtils.getList('hibernate.hbm')}"/>
<property name="hibernateProperties">
<value>
hibernate.dialect=${hibernate.dialect}
hibernate.show_sql=false
hibernate.format_sql=false
hibernate.query.substitutions=true 1, false 0
hibernate.jdbc.batch_size=20
hibernate.cache.use_query_cache=true
<!-- 新增 -->
hibernate.autoReconnect=true
</value>
</property>
<property name="entityInterceptor">   
<ref local="treeInterceptor"/>
</property>
<property name="cacheProvider">
<ref local="cacheProvider"/>
</property>
<property name="lobHandler">
<ref bean="lobHandler" />
</property>
</bean>
<bean id="lobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" lazy-init="true"/>

<bean id="cacheProvider" class="com.jeecms.common.hibernate3.SpringEhCacheProvider">
<property name="configLocation">
<value>/WEB-INF/config/ehcache-hibernate.xml</value>
</property>
<property name="diskStoreLocation">
<value>/WEB-INF/cache/hibernate</value>
</property>
</bean>
<bean id="treeInterceptor" class="com.jeecms.common.hibernate3.TreeIntercptor"/>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<context:annotation-config/>
<tx:annotation-driven transaction-manager="transactionManager" />
</beans>
级别: 版主
UID: 70293
积分:78391 加为好友
威望: 1 精华: 0
主题:7 回复:68397
注册时间:2014-12-03
在线时长:0
24#   发表于:2015-09-10 09:48:38  IP:106.189.*.*
1
|< < 1 2 3 共3页