在刷新一次就没事了 这是为什么啊?
谢谢各位了
<logic:notPresent name="uptotheminute" scope="request">
<jsp:forward page="/messageInfo.do?operate=toListYan"/>
</logic:notPresent>
这段代码 经常出现,本地测试的时候什么事都没有
org.apache.jasper.JasperException: javax.servlet.ServletException: org.hibernate.exception.GenericJDBCException: could not inspect JDBC autocommit mode
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
javax.servlet.ServletException: org.hibernate.exception.GenericJDBCException: could not inspect JDBC autocommit mode
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:535)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:433)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:696)
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:667)
org.apache.jsp.index_jsp._jspx_meth_logic_005fnotPresent_005f0(index_jsp.java:900)
org.apache.jsp.index_jsp._jspService(index_jsp.java:95)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
org.hibernate.exception.GenericJDBCException: could not inspect JDBC autocommit mode
org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
org.hibernate.jdbc.JDBCContext.afterNontransactionalQuery(JDBCContext.java:232)
org.hibernate.impl.SessionImpl.afterOperation(SessionImpl.java:412)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1111)
org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
com.dao.CommonDAOHibImpl.list(CommonDAOHibImpl.java:41)
com.biz.MessageInfoBizImpl.getlistgonggaoyan(MessageInfoBizImpl.java:78)
com.yourcompany.struts.action.MessageInfoAction.toLisetgonggaoYan(MessageInfoAction.java:462)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:110)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:696)
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:667)
org.apache.jsp.index_jsp._jspx_meth_logic_005fnotPresent_005f0(index_jsp.java:900)
org.apache.jsp.index_jsp._jspService(index_jsp.java:95)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
com.microsoft.sqlserver.jdbc.SQLServerException: 该连接已关闭。
com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerConnection.checkClosed(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerConnection.getAutoCommit(Unknown Source)
org.apache.commons.dbcp.DelegatingConnection.getAutoCommit(DelegatingConnection.java:304)
org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.getAutoCommit(PoolingDataSource.java:224)
org.hibernate.jdbc.ConnectionManager.isAutoCommit(ConnectionManager.java:185)
org.hibernate.jdbc.JDBCContext.afterNontransactionalQuery(JDBCContext.java:223)
org.hibernate.impl.SessionImpl.afterOperation(SessionImpl.java:412)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1111)
org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
com.dao.CommonDAOHibImpl.list(CommonDAOHibImpl.java:41)
com.biz.MessageInfoBizImpl.getlistgonggaoyan(MessageInfoBizImpl.java:78)
com.yourcompany.struts.action.MessageInfoAction.toLisetgonggaoYan(MessageInfoAction.java:462)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:110)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:696)
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:667)
org.apache.jsp.index_jsp._jspx_meth_logic_005fnotPresent_005f0(index_jsp.java:900)
org.apache.jsp.index_jsp._jspService(index_jsp.java:95)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
3 个解决方案
#1
Action里面有
public ActionForward toLisetgonggaoYan(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
MessageInfoForm messageInfoForm = (MessageInfoForm) form;
MessageInfo mi1= biz.getlistgonggaoyan(1);
if(mi1.getTitle().length()>11)
{
mi1.setTitle( mi1.getTitle().substring(0, 11)+"...");
}
if(mi1.getHdtime().length()>11)
{
mi1.setHdtime( mi1.getHdtime().substring(0, 11)+"...");
}
if(mi1.getContents().length()>40)
{
mi1.setContents( mi1.getContents().substring(0, 40)+"...");
}
request.setAttribute("zuixingonggao", mi1);
List l= biz.getListfromdongtaiyan();
List list=new ArrayList();
for(int i=0;i<l.size();i++)
{
MessageInfo mi2 =(MessageInfo)l.get(i);
if(mi2.getTitle().length()>10)
{
mi2.setTitle(mi2.getTitle().substring(0, 10)+"...");
}
list.add(mi2);
}
request.setAttribute("zuixindongtai", list);
MessageInfo mi =biz.getlistgonggaoyan(3);
if(mi.getContents().length()>70)
{
mi.setContents(mi.getContents().substring(0, 70));
}
request.setAttribute("yemanjianjie", mi);
request.setAttribute("zhongyaohuodong", biz.getListfromhuodongyan());
List l2=biz.getListyueduyan();
List list2=new ArrayList();
for(int i=0;i<l2.size();i++)
{
MessageInfo mi3= (MessageInfo)l2.get(i);
if(mi3.getTitle().length()>14)
{
mi3.setTitle( mi3.getTitle().substring(0, 14)+"...");
}
list2.add(mi3);
}
request.setAttribute("wenzhangyuedu",list2 );
String ym=request.getParameter("ym");
return mapping.findForward("index");
}
public ActionForward toLisetgonggaoYan(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
MessageInfoForm messageInfoForm = (MessageInfoForm) form;
MessageInfo mi1= biz.getlistgonggaoyan(1);
if(mi1.getTitle().length()>11)
{
mi1.setTitle( mi1.getTitle().substring(0, 11)+"...");
}
if(mi1.getHdtime().length()>11)
{
mi1.setHdtime( mi1.getHdtime().substring(0, 11)+"...");
}
if(mi1.getContents().length()>40)
{
mi1.setContents( mi1.getContents().substring(0, 40)+"...");
}
request.setAttribute("zuixingonggao", mi1);
List l= biz.getListfromdongtaiyan();
List list=new ArrayList();
for(int i=0;i<l.size();i++)
{
MessageInfo mi2 =(MessageInfo)l.get(i);
if(mi2.getTitle().length()>10)
{
mi2.setTitle(mi2.getTitle().substring(0, 10)+"...");
}
list.add(mi2);
}
request.setAttribute("zuixindongtai", list);
MessageInfo mi =biz.getlistgonggaoyan(3);
if(mi.getContents().length()>70)
{
mi.setContents(mi.getContents().substring(0, 70));
}
request.setAttribute("yemanjianjie", mi);
request.setAttribute("zhongyaohuodong", biz.getListfromhuodongyan());
List l2=biz.getListyueduyan();
List list2=new ArrayList();
for(int i=0;i<l2.size();i++)
{
MessageInfo mi3= (MessageInfo)l2.get(i);
if(mi3.getTitle().length()>14)
{
mi3.setTitle( mi3.getTitle().substring(0, 14)+"...");
}
list2.add(mi3);
}
request.setAttribute("wenzhangyuedu",list2 );
String ym=request.getParameter("ym");
return mapping.findForward("index");
}
#2
com.microsoft.sqlserver.jdbc.SQLServerException: 该连接已关闭。
com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerConnection.checkClosed(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerConnection.getAutoCommit(Unknown Source)
连接对象有问题。在使用一个已关闭的连接。
com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerConnection.checkClosed(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerConnection.getAutoCommit(Unknown Source)
连接对象有问题。在使用一个已关闭的连接。
#3
朋友 能不能说的在详细点啊 我这是 SSH框架的 那怎么改啊
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.microsoft.sqlserver.jdbc.SQLServerDriver">
</property>
<property name="url"
value="jdbc:sqlserver://WWW-9F4138645B9:1433;databaseName=yeman">
</property>
<property name="username" value="sa"></property>
<property name="password" value="123"></property>
</bean>
<bean id="yemanSession"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
<!-- 缓存 -->
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.use_sql_comments">true </prop>
<prop key="hibernate.default_batch_fetch_size">10 </prop>
<prop key="hibernate.jdbc.fetch_size">10 </prop>
<prop key="hibernate.jdbc.batch_size">5 </prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/enety/AskAnswer.hbm.xml</value>
<value>com/enety/User.hbm.xml</value>
<value>com/enety/FriendLink.hbm.xml</value>
<value>com/enety/Advise.hbm.xml</value>
<value>com/enety/CoursePlan.hbm.xml</value>
<value>com/enety/MessageType.hbm.xml</value>
<value>com/enety/MessageInfo.hbm.xml</value>
<value>com/enety/MediaMgr.hbm.xml</value>
<value>com/enety/AnswerType.hbm.xml</value>
<value>com/enety/Users.hbm.xml</value></list>
</property></bean>
<bean id="TransactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="yemanSession" />
</bean>
<!-- comm -->
<bean id="CommonDAOHibImpl" class="com.dao.CommonDAOHibImpl">
<property name="sessionFactory">
<ref bean="yemanSession" />
</property>
<!-- user -->
</bean>
<bean id="UserBizImpl" class="com.biz.UserBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/user" class="com.yourcompany.struts.action.UserAction">
<property name="biz">
<ref bean="UserBizImpl" />
</property>
</bean>
<!-- MessageInfo -->
<bean id="MessageInfoBizImpl" class="com.biz.MessageInfoBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/messageInfo" class="com.yourcompany.struts.action.MessageInfoAction">
<property name="biz">
<ref bean="MessageInfoBizImpl" />
</property>
</bean>
<!-- MediaMgr -->
<bean id="MediaMgrBizImpl" class="com.biz.MediaMgrBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/mediaMgr" class="com.yourcompany.struts.action.MediaMgrAction">
<property name="biz">
<ref bean="MediaMgrBizImpl" />
</property>
</bean>
<!-- FriendLink -->
<bean id="FriendLinkBizImpl" class="com.biz.FriendLinkBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/friendLink" class="com.yourcompany.struts.action.FriendLinkAction">
<property name="biz">
<ref bean="FriendLinkBizImpl" />
</property>
</bean>
<!-- CoursePlan -->
<bean id="CoursePlanBizImpl" class="com.biz.CoursePlanBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/coursePlan" class="com.yourcompany.struts.action.CoursePlanAction">
<property name="biz">
<ref bean="CoursePlanBizImpl" />
</property>
</bean>
<!-- AskAnswer -->
<bean id="AskAnswerBizImpl" class="com.biz.AskAnswerBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/askAnswer" class="com.yourcompany.struts.action.AskAnswerAction">
<property name="biz">
<ref bean="AskAnswerBizImpl" />
</property>
</bean>
<!-- AnswerType -->
<bean id="AnswerTypeBizImol" class="com.biz.AnswerTypeBizImol">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/answerType" class="com.yourcompany.struts.action.AnswerTypeAction">
<property name="biz">
<ref bean="AnswerTypeBizImol" />
</property>
</bean>
<!-- Advise -->
<bean id="AdviseBizImpl" class="com.biz.AdviseBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/advise" class="com.yourcompany.struts.action.AdviseAction">
<property name="biz">
<ref bean="AdviseBizImpl" />
</property>
</bean>
</beans>
<?xml version="1.0" encoding="gb2312"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean id="TransactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="yemanSession" />
</bean>
<!--声明一个通知,用以指出要管理哪些事务方法及如何管理-->
<tx:advice id="txAdvice" transaction-manager="TransactionManager">
<tx:attributes>
<!-- 对get/load/search开头的方法要求只读事务 -->
<tx:method name="get*" propagation="SUPPORTS"
read-only="true" />
<tx:method name="load*" propagation="SUPPORTS"
read-only="true" />
<tx:method name="search*" propagation="SUPPORTS"
read-only="true" />
<!-- 对其它方法要求事务 -->
<tx:method name="*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<!--声明一个config,用以将通知和目标业务类关联起来-->
<aop:config>
<!-- 添加事务支持,因为前面配置的transactionManager是专对Hibernate的事务管理器-->
<aop:pointcut id="bizMethods"
expression="execution(* com.crm.Biz.*.*(..))" />
<!-- 织入 -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="bizMethods" />
</aop:config>
</beans>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.microsoft.sqlserver.jdbc.SQLServerDriver">
</property>
<property name="url"
value="jdbc:sqlserver://WWW-9F4138645B9:1433;databaseName=yeman">
</property>
<property name="username" value="sa"></property>
<property name="password" value="123"></property>
</bean>
<bean id="yemanSession"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
<!-- 缓存 -->
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.use_sql_comments">true </prop>
<prop key="hibernate.default_batch_fetch_size">10 </prop>
<prop key="hibernate.jdbc.fetch_size">10 </prop>
<prop key="hibernate.jdbc.batch_size">5 </prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/enety/AskAnswer.hbm.xml</value>
<value>com/enety/User.hbm.xml</value>
<value>com/enety/FriendLink.hbm.xml</value>
<value>com/enety/Advise.hbm.xml</value>
<value>com/enety/CoursePlan.hbm.xml</value>
<value>com/enety/MessageType.hbm.xml</value>
<value>com/enety/MessageInfo.hbm.xml</value>
<value>com/enety/MediaMgr.hbm.xml</value>
<value>com/enety/AnswerType.hbm.xml</value>
<value>com/enety/Users.hbm.xml</value></list>
</property></bean>
<bean id="TransactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="yemanSession" />
</bean>
<!-- comm -->
<bean id="CommonDAOHibImpl" class="com.dao.CommonDAOHibImpl">
<property name="sessionFactory">
<ref bean="yemanSession" />
</property>
<!-- user -->
</bean>
<bean id="UserBizImpl" class="com.biz.UserBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/user" class="com.yourcompany.struts.action.UserAction">
<property name="biz">
<ref bean="UserBizImpl" />
</property>
</bean>
<!-- MessageInfo -->
<bean id="MessageInfoBizImpl" class="com.biz.MessageInfoBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/messageInfo" class="com.yourcompany.struts.action.MessageInfoAction">
<property name="biz">
<ref bean="MessageInfoBizImpl" />
</property>
</bean>
<!-- MediaMgr -->
<bean id="MediaMgrBizImpl" class="com.biz.MediaMgrBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/mediaMgr" class="com.yourcompany.struts.action.MediaMgrAction">
<property name="biz">
<ref bean="MediaMgrBizImpl" />
</property>
</bean>
<!-- FriendLink -->
<bean id="FriendLinkBizImpl" class="com.biz.FriendLinkBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/friendLink" class="com.yourcompany.struts.action.FriendLinkAction">
<property name="biz">
<ref bean="FriendLinkBizImpl" />
</property>
</bean>
<!-- CoursePlan -->
<bean id="CoursePlanBizImpl" class="com.biz.CoursePlanBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/coursePlan" class="com.yourcompany.struts.action.CoursePlanAction">
<property name="biz">
<ref bean="CoursePlanBizImpl" />
</property>
</bean>
<!-- AskAnswer -->
<bean id="AskAnswerBizImpl" class="com.biz.AskAnswerBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/askAnswer" class="com.yourcompany.struts.action.AskAnswerAction">
<property name="biz">
<ref bean="AskAnswerBizImpl" />
</property>
</bean>
<!-- AnswerType -->
<bean id="AnswerTypeBizImol" class="com.biz.AnswerTypeBizImol">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/answerType" class="com.yourcompany.struts.action.AnswerTypeAction">
<property name="biz">
<ref bean="AnswerTypeBizImol" />
</property>
</bean>
<!-- Advise -->
<bean id="AdviseBizImpl" class="com.biz.AdviseBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/advise" class="com.yourcompany.struts.action.AdviseAction">
<property name="biz">
<ref bean="AdviseBizImpl" />
</property>
</bean>
</beans>
<?xml version="1.0" encoding="gb2312"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean id="TransactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="yemanSession" />
</bean>
<!--声明一个通知,用以指出要管理哪些事务方法及如何管理-->
<tx:advice id="txAdvice" transaction-manager="TransactionManager">
<tx:attributes>
<!-- 对get/load/search开头的方法要求只读事务 -->
<tx:method name="get*" propagation="SUPPORTS"
read-only="true" />
<tx:method name="load*" propagation="SUPPORTS"
read-only="true" />
<tx:method name="search*" propagation="SUPPORTS"
read-only="true" />
<!-- 对其它方法要求事务 -->
<tx:method name="*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<!--声明一个config,用以将通知和目标业务类关联起来-->
<aop:config>
<!-- 添加事务支持,因为前面配置的transactionManager是专对Hibernate的事务管理器-->
<aop:pointcut id="bizMethods"
expression="execution(* com.crm.Biz.*.*(..))" />
<!-- 织入 -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="bizMethods" />
</aop:config>
</beans>
#1
Action里面有
public ActionForward toLisetgonggaoYan(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
MessageInfoForm messageInfoForm = (MessageInfoForm) form;
MessageInfo mi1= biz.getlistgonggaoyan(1);
if(mi1.getTitle().length()>11)
{
mi1.setTitle( mi1.getTitle().substring(0, 11)+"...");
}
if(mi1.getHdtime().length()>11)
{
mi1.setHdtime( mi1.getHdtime().substring(0, 11)+"...");
}
if(mi1.getContents().length()>40)
{
mi1.setContents( mi1.getContents().substring(0, 40)+"...");
}
request.setAttribute("zuixingonggao", mi1);
List l= biz.getListfromdongtaiyan();
List list=new ArrayList();
for(int i=0;i<l.size();i++)
{
MessageInfo mi2 =(MessageInfo)l.get(i);
if(mi2.getTitle().length()>10)
{
mi2.setTitle(mi2.getTitle().substring(0, 10)+"...");
}
list.add(mi2);
}
request.setAttribute("zuixindongtai", list);
MessageInfo mi =biz.getlistgonggaoyan(3);
if(mi.getContents().length()>70)
{
mi.setContents(mi.getContents().substring(0, 70));
}
request.setAttribute("yemanjianjie", mi);
request.setAttribute("zhongyaohuodong", biz.getListfromhuodongyan());
List l2=biz.getListyueduyan();
List list2=new ArrayList();
for(int i=0;i<l2.size();i++)
{
MessageInfo mi3= (MessageInfo)l2.get(i);
if(mi3.getTitle().length()>14)
{
mi3.setTitle( mi3.getTitle().substring(0, 14)+"...");
}
list2.add(mi3);
}
request.setAttribute("wenzhangyuedu",list2 );
String ym=request.getParameter("ym");
return mapping.findForward("index");
}
public ActionForward toLisetgonggaoYan(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
MessageInfoForm messageInfoForm = (MessageInfoForm) form;
MessageInfo mi1= biz.getlistgonggaoyan(1);
if(mi1.getTitle().length()>11)
{
mi1.setTitle( mi1.getTitle().substring(0, 11)+"...");
}
if(mi1.getHdtime().length()>11)
{
mi1.setHdtime( mi1.getHdtime().substring(0, 11)+"...");
}
if(mi1.getContents().length()>40)
{
mi1.setContents( mi1.getContents().substring(0, 40)+"...");
}
request.setAttribute("zuixingonggao", mi1);
List l= biz.getListfromdongtaiyan();
List list=new ArrayList();
for(int i=0;i<l.size();i++)
{
MessageInfo mi2 =(MessageInfo)l.get(i);
if(mi2.getTitle().length()>10)
{
mi2.setTitle(mi2.getTitle().substring(0, 10)+"...");
}
list.add(mi2);
}
request.setAttribute("zuixindongtai", list);
MessageInfo mi =biz.getlistgonggaoyan(3);
if(mi.getContents().length()>70)
{
mi.setContents(mi.getContents().substring(0, 70));
}
request.setAttribute("yemanjianjie", mi);
request.setAttribute("zhongyaohuodong", biz.getListfromhuodongyan());
List l2=biz.getListyueduyan();
List list2=new ArrayList();
for(int i=0;i<l2.size();i++)
{
MessageInfo mi3= (MessageInfo)l2.get(i);
if(mi3.getTitle().length()>14)
{
mi3.setTitle( mi3.getTitle().substring(0, 14)+"...");
}
list2.add(mi3);
}
request.setAttribute("wenzhangyuedu",list2 );
String ym=request.getParameter("ym");
return mapping.findForward("index");
}
#2
com.microsoft.sqlserver.jdbc.SQLServerException: 该连接已关闭。
com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerConnection.checkClosed(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerConnection.getAutoCommit(Unknown Source)
连接对象有问题。在使用一个已关闭的连接。
com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerConnection.checkClosed(Unknown Source)
com.microsoft.sqlserver.jdbc.SQLServerConnection.getAutoCommit(Unknown Source)
连接对象有问题。在使用一个已关闭的连接。
#3
朋友 能不能说的在详细点啊 我这是 SSH框架的 那怎么改啊
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.microsoft.sqlserver.jdbc.SQLServerDriver">
</property>
<property name="url"
value="jdbc:sqlserver://WWW-9F4138645B9:1433;databaseName=yeman">
</property>
<property name="username" value="sa"></property>
<property name="password" value="123"></property>
</bean>
<bean id="yemanSession"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
<!-- 缓存 -->
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.use_sql_comments">true </prop>
<prop key="hibernate.default_batch_fetch_size">10 </prop>
<prop key="hibernate.jdbc.fetch_size">10 </prop>
<prop key="hibernate.jdbc.batch_size">5 </prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/enety/AskAnswer.hbm.xml</value>
<value>com/enety/User.hbm.xml</value>
<value>com/enety/FriendLink.hbm.xml</value>
<value>com/enety/Advise.hbm.xml</value>
<value>com/enety/CoursePlan.hbm.xml</value>
<value>com/enety/MessageType.hbm.xml</value>
<value>com/enety/MessageInfo.hbm.xml</value>
<value>com/enety/MediaMgr.hbm.xml</value>
<value>com/enety/AnswerType.hbm.xml</value>
<value>com/enety/Users.hbm.xml</value></list>
</property></bean>
<bean id="TransactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="yemanSession" />
</bean>
<!-- comm -->
<bean id="CommonDAOHibImpl" class="com.dao.CommonDAOHibImpl">
<property name="sessionFactory">
<ref bean="yemanSession" />
</property>
<!-- user -->
</bean>
<bean id="UserBizImpl" class="com.biz.UserBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/user" class="com.yourcompany.struts.action.UserAction">
<property name="biz">
<ref bean="UserBizImpl" />
</property>
</bean>
<!-- MessageInfo -->
<bean id="MessageInfoBizImpl" class="com.biz.MessageInfoBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/messageInfo" class="com.yourcompany.struts.action.MessageInfoAction">
<property name="biz">
<ref bean="MessageInfoBizImpl" />
</property>
</bean>
<!-- MediaMgr -->
<bean id="MediaMgrBizImpl" class="com.biz.MediaMgrBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/mediaMgr" class="com.yourcompany.struts.action.MediaMgrAction">
<property name="biz">
<ref bean="MediaMgrBizImpl" />
</property>
</bean>
<!-- FriendLink -->
<bean id="FriendLinkBizImpl" class="com.biz.FriendLinkBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/friendLink" class="com.yourcompany.struts.action.FriendLinkAction">
<property name="biz">
<ref bean="FriendLinkBizImpl" />
</property>
</bean>
<!-- CoursePlan -->
<bean id="CoursePlanBizImpl" class="com.biz.CoursePlanBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/coursePlan" class="com.yourcompany.struts.action.CoursePlanAction">
<property name="biz">
<ref bean="CoursePlanBizImpl" />
</property>
</bean>
<!-- AskAnswer -->
<bean id="AskAnswerBizImpl" class="com.biz.AskAnswerBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/askAnswer" class="com.yourcompany.struts.action.AskAnswerAction">
<property name="biz">
<ref bean="AskAnswerBizImpl" />
</property>
</bean>
<!-- AnswerType -->
<bean id="AnswerTypeBizImol" class="com.biz.AnswerTypeBizImol">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/answerType" class="com.yourcompany.struts.action.AnswerTypeAction">
<property name="biz">
<ref bean="AnswerTypeBizImol" />
</property>
</bean>
<!-- Advise -->
<bean id="AdviseBizImpl" class="com.biz.AdviseBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/advise" class="com.yourcompany.struts.action.AdviseAction">
<property name="biz">
<ref bean="AdviseBizImpl" />
</property>
</bean>
</beans>
<?xml version="1.0" encoding="gb2312"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean id="TransactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="yemanSession" />
</bean>
<!--声明一个通知,用以指出要管理哪些事务方法及如何管理-->
<tx:advice id="txAdvice" transaction-manager="TransactionManager">
<tx:attributes>
<!-- 对get/load/search开头的方法要求只读事务 -->
<tx:method name="get*" propagation="SUPPORTS"
read-only="true" />
<tx:method name="load*" propagation="SUPPORTS"
read-only="true" />
<tx:method name="search*" propagation="SUPPORTS"
read-only="true" />
<!-- 对其它方法要求事务 -->
<tx:method name="*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<!--声明一个config,用以将通知和目标业务类关联起来-->
<aop:config>
<!-- 添加事务支持,因为前面配置的transactionManager是专对Hibernate的事务管理器-->
<aop:pointcut id="bizMethods"
expression="execution(* com.crm.Biz.*.*(..))" />
<!-- 织入 -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="bizMethods" />
</aop:config>
</beans>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.microsoft.sqlserver.jdbc.SQLServerDriver">
</property>
<property name="url"
value="jdbc:sqlserver://WWW-9F4138645B9:1433;databaseName=yeman">
</property>
<property name="username" value="sa"></property>
<property name="password" value="123"></property>
</bean>
<bean id="yemanSession"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
<!-- 缓存 -->
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.use_sql_comments">true </prop>
<prop key="hibernate.default_batch_fetch_size">10 </prop>
<prop key="hibernate.jdbc.fetch_size">10 </prop>
<prop key="hibernate.jdbc.batch_size">5 </prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/enety/AskAnswer.hbm.xml</value>
<value>com/enety/User.hbm.xml</value>
<value>com/enety/FriendLink.hbm.xml</value>
<value>com/enety/Advise.hbm.xml</value>
<value>com/enety/CoursePlan.hbm.xml</value>
<value>com/enety/MessageType.hbm.xml</value>
<value>com/enety/MessageInfo.hbm.xml</value>
<value>com/enety/MediaMgr.hbm.xml</value>
<value>com/enety/AnswerType.hbm.xml</value>
<value>com/enety/Users.hbm.xml</value></list>
</property></bean>
<bean id="TransactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="yemanSession" />
</bean>
<!-- comm -->
<bean id="CommonDAOHibImpl" class="com.dao.CommonDAOHibImpl">
<property name="sessionFactory">
<ref bean="yemanSession" />
</property>
<!-- user -->
</bean>
<bean id="UserBizImpl" class="com.biz.UserBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/user" class="com.yourcompany.struts.action.UserAction">
<property name="biz">
<ref bean="UserBizImpl" />
</property>
</bean>
<!-- MessageInfo -->
<bean id="MessageInfoBizImpl" class="com.biz.MessageInfoBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/messageInfo" class="com.yourcompany.struts.action.MessageInfoAction">
<property name="biz">
<ref bean="MessageInfoBizImpl" />
</property>
</bean>
<!-- MediaMgr -->
<bean id="MediaMgrBizImpl" class="com.biz.MediaMgrBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/mediaMgr" class="com.yourcompany.struts.action.MediaMgrAction">
<property name="biz">
<ref bean="MediaMgrBizImpl" />
</property>
</bean>
<!-- FriendLink -->
<bean id="FriendLinkBizImpl" class="com.biz.FriendLinkBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/friendLink" class="com.yourcompany.struts.action.FriendLinkAction">
<property name="biz">
<ref bean="FriendLinkBizImpl" />
</property>
</bean>
<!-- CoursePlan -->
<bean id="CoursePlanBizImpl" class="com.biz.CoursePlanBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/coursePlan" class="com.yourcompany.struts.action.CoursePlanAction">
<property name="biz">
<ref bean="CoursePlanBizImpl" />
</property>
</bean>
<!-- AskAnswer -->
<bean id="AskAnswerBizImpl" class="com.biz.AskAnswerBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/askAnswer" class="com.yourcompany.struts.action.AskAnswerAction">
<property name="biz">
<ref bean="AskAnswerBizImpl" />
</property>
</bean>
<!-- AnswerType -->
<bean id="AnswerTypeBizImol" class="com.biz.AnswerTypeBizImol">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/answerType" class="com.yourcompany.struts.action.AnswerTypeAction">
<property name="biz">
<ref bean="AnswerTypeBizImol" />
</property>
</bean>
<!-- Advise -->
<bean id="AdviseBizImpl" class="com.biz.AdviseBizImpl">
<property name="dao">
<ref bean="CommonDAOHibImpl" />
</property>
</bean>
<bean name="/advise" class="com.yourcompany.struts.action.AdviseAction">
<property name="biz">
<ref bean="AdviseBizImpl" />
</property>
</bean>
</beans>
<?xml version="1.0" encoding="gb2312"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean id="TransactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="yemanSession" />
</bean>
<!--声明一个通知,用以指出要管理哪些事务方法及如何管理-->
<tx:advice id="txAdvice" transaction-manager="TransactionManager">
<tx:attributes>
<!-- 对get/load/search开头的方法要求只读事务 -->
<tx:method name="get*" propagation="SUPPORTS"
read-only="true" />
<tx:method name="load*" propagation="SUPPORTS"
read-only="true" />
<tx:method name="search*" propagation="SUPPORTS"
read-only="true" />
<!-- 对其它方法要求事务 -->
<tx:method name="*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<!--声明一个config,用以将通知和目标业务类关联起来-->
<aop:config>
<!-- 添加事务支持,因为前面配置的transactionManager是专对Hibernate的事务管理器-->
<aop:pointcut id="bizMethods"
expression="execution(* com.crm.Biz.*.*(..))" />
<!-- 织入 -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="bizMethods" />
</aop:config>
</beans>