Spring 纯jdbc JdbcDaoSupport 事务处理

        PlatformTransactionManager ptm = new DataSourceTransactionManager(this.getDataSource());
        DefaultTransactionDefinition def = new DefaultTransactionDefinition();
        TransactionStatus status = ptm.getTransaction(def);
        try {
            String _deleteSql = "delete from sdc_StockIndustryRela where industryCode='" + industrycode + "' and relationtype=" + partmode;
            getJdbcTemplate().execute(_deleteSql);
            String _deleteIndustrySql = "delete from sdc_industrypartition where partmode=" + partmode + " and industrycode like '" + industrycode + "%'";
            getJdbcTemplate().execute(_deleteIndustrySql);
            ptm.commit(status);
        } catch (Exception e) {
            ptm.rollback(status);
        }

猜你喜欢

转载自liujianshiwo.iteye.com/blog/1069551