spring 事物不回滚

<beanid="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
    <propertyname="driverClass" value="${jdbc.driverClassName}"/>

    <propertyname="jdbcUrl" value="${jdbc.url}"/>

    <propertyname="user" value="${jdbc.username}"/>

    <propertyname="password" value="${jdbc.password}"/>

    <!--连接池中保留的最大连接数 -->
<propertyname="maxPoolSize" value="50"/>

    <!--连接池中保留的最小连接数。-->
<propertyname="minPoolSize" value="5"/>

    <!--初始化时获取的连接数,取值应在minPoolSize与maxPoolSize之间。Default: 5 -->
<propertyname="initialPoolSize" value="5"/>

    <!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 -->
<propertyname="acquireIncrement" value="5"/>

    <!--最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->
<propertyname="maxIdleTime" value="300"/>

    <!--定义在从数据库获取新连接失败后重复尝试的次数。Default: 30 -->
<propertyname="acquireRetryAttempts" value="1"></property>
</bean>

<!-- 使用jdbcTemplate模版 -->
<beanid="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
    <propertyname="dataSource" ref="dataSource"/>
</bean>

<!-- 配置Srping JDBC 事务 -->
<beanid="jdbcTransactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <propertyname="dataSource">
        <reflocal="dataSource"/>
    </property>
</bean>

<!-- 开启jdbc注解事务 -->
<tx:annotation-driventransaction-manager="jdbcTransactionManager"/>

 

 

 

oracle数据库,使用事物的时候总是不回滚

@Service("testService")
publicclassTestServiceImpl implementsTestService {

    @Resource
privateActivityDao activityDao;

    @Override
    @Transactional(rollbackFor = IhkMsyfException.class)
    publicvoidsaveTest() throwsIhkMsyfException {
        try{
            Activity activity = newActivity();
            activity.setCreateTime(newDate());
            activity.setName("test");
            activity.setActivityUrl("test");
            activity.setAwardCount(1);
            activity.setAwardDay(1);
            activity.setContent("test");
            activity.setEndTime(newDate());
            activity.setIconUrl("");
            activity.setOdds(1);
            activity.setSceneId("123");
            activity.setShareUrl("test");
            activity.setStartTime(newDate());
            activity.setStatus(false);
            activity.setTypeId(1l);
            activity.setUserCount(1);
            Long k = activityDao.save(activity);
//            activity.setId(k);
//            activity.setName("testesstsetset");
//            activityDao.update(activity);
thrownewRuntimeException();
        } catch(Exception e) {
            IhkMsyfException.myPrintStackTrace(e);
            thrownewIhkMsyfException();
        }
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值