zl程序教程

您现在的位置是:首页 >  后端

当前栏目

手动设置事务提交

事务 设置 提交 手动
2023-09-27 14:21:38 时间
 @Override
    @Transactional(readOnly = false, rollbackFor = Throwable.class)
    public void updateIsSyncFromSynchroodata(Paynote paynote) {
        int count = 0;
        try {
            //设置手动提交
            this.defaultDao.getJdbcTemplate().getDataSource().getConnection().setAutoCommit(false);
            String update_sql="update t_paynote set is_sync='"+paynote.getIsSync()+"',proctime='"+paynote.getProctime()+"' where pn_no='"+paynote.getPnNo()+"' and unit_no='"+paynote.getUnitNo()+"' and orderno='"+paynote.getOrderno()+"'";
            count= this.defaultDao.getJdbcTemplate().update( update_sql);
            this.defaultDao.getJdbcTemplate().getDataSource().getConnection().commit();
        }catch (Exception e) {
            e.printStackTrace();
            try {
                this.defaultDao.getJdbcTemplate().getDataSource().getConnection().rollback();
            } catch (SQLException e1) {
                e1.printStackTrace();
            }
        }finally {
            try {
                this.defaultDao.getJdbcTemplate().getDataSource().getConnection().setAutoCommit(true);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }