最近 项目 线上 环境 偶尔 爆 如下 异常org.springframework.transaction.TransactionSystemException: Could not roll back JDBC transaction; nested exception is java.sql.SQLException: Closed Connection
用的是 dbcp连接池各位可遇到类似 的情况呢?怎么解决呢?
用的是 dbcp连接池各位可遇到类似 的情况呢?怎么解决呢?
解决方案 »
- Integer.parseInt( )的使用
- 请教:定义一个Student类,要求在程序中生成若干个Student对象,并将这些对象分别保存到ArrayList和HashSet中,然后遍历的输出出来。我这样
- 七夕一个人过,顺便散分
- 怎样删除文件中指定的一行
- 求一个java操作关系数据库的例子
- 求救!!!!!zip包里有中文文件名解压时报错
- 一段代码的解析
- 有什么办法可以把JTree的数据,转成一个XML文件?有解的绝对给50分,不食言
- 如何在redhat9.0中安装jdk
- 新手送分题~~~~
- 怎么把从数据库读取的数据存入列表框???????
- 收藏 不显示删除回复显示所有回复显示星级回复显示得分回复 关于Exception in thread "AWT-EventQueue-0" java.lang.
2。但报出的异常也许是其它原因造成的,
3。可能是你的commit的connection的rollback的根本就是同一个。
4。也有可能是说你可能线程里不安全。
<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: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/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<aop:aspectj-autoproxy proxy-target-class="true"/> <aop:config proxy-target-class="false">
<aop:advisor id="managerTx" advice-ref="txAdvice"
pointcut="execution(* *..service..*ServiceImpl.*(..))" order="0" />
</aop:config>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*" propagation="NESTED"/>
</tx:attributes>
</tx:advice></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.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
<!-- 定义数据源Bean,使用C3P0数据源实现 -->
<bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<!-- 指定连接数据库的驱动 -->
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<!-- 指定连接数据库的URL -->
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/数据库名称" />
<!-- 指定连接数据库的用户名 -->
<property name="user" value="root" />
<!-- 指定连接数据库的密码 -->
<property name="password" value="" />
<!-- 指定连接数据库连接池的最大连接数 -->
<property name="maxPoolSize" value="40" />
<!-- 指定连接数据库连接池的最小连接数 -->
<property name="minPoolSize" value="1" />
<!-- 指定连接数据库连接池的初始化连接数 -->
<property name="initialPoolSize" value="1" />
<!-- 指定连接数据库连接池的连接的最大空闲时间 -->
<property name="maxIdleTime" value="20" />
</bean> <!-- 定义Hibernate的SessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!-- 依赖注入数据源,注入正是上面定义的dataSource -->
<property name="dataSource" ref="dataSource" />
<!-- mappingResouces属性用来列出全部映射文件 -->
<property name="mappingResources">
<list>
<!-- 以下用来列出Hibernate映射文件 -->
<value>包名/xxx.hbm.xml</value> </list>
</property>
<!-- 定义Hibernate的SessionFactory的属性 -->
<property name="hibernateProperties">
<props>
<!-- 指定数据库方言 -->
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLInnoDBDialect
</prop>
<!-- 是否根据需要每次自动创建数据库 -->
<prop key="hibernate.hbm2ddl.auto">update</prop>
<!-- 显示Hibernate持久化操作所生成的SQL -->
<prop key="hibernate.show_sql">true</prop>
<!-- 将SQL脚本进行格式化后再输出 -->
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
</bean> <!-- 配置Hibernate的局部事务管理器,使用HibernateTransactionManager类 -->
<!-- 该类实现PlatformTransactionManager接口,是针对Hibernate的特定实现-->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<!-- 配置HibernateTransactionManager时需要依注入SessionFactory的引用 -->
<property name="sessionFactory" ref="sessionFactory" />
</bean> <!-- 配置事务切面Bean,指定事务管理器 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<!-- 用于配置详细的事务语义 -->
<tx:attributes>
<!-- 所有以'xxx'开头的方法是read-only的 -->
<tx:method name="xxx*" read-only="true" />
<!-- 其他方法使用默认的事务设置 -->
<tx:method name="*" />
</tx:attributes>
</tx:advice> <aop:config>
<!-- 配置一个切入点,匹配某某某包下
所有以Impl结尾的类的所有方法的执行 -->
<aop:pointcut id="leePointcut"
expression="execution(* 包名.*Impl.*(..))" />
<!-- 指定在leePointcut切入点应用txAdvice事务切面 -->
<aop:advisor advice-ref="txAdvice" pointcut-ref="leePointcut" />
</aop:config>
</beans>
也有可能是说你可能线程里不安全。