Tag:jdbctemplate

  • Example of adding transaction support to JDBC template in spring

    Time:2020-10-27

    Copy codeThe code is as follows: public interface JdbcTemplate extends JdbcOperations {public abstract void beginTranstaion(); public abstract void commit(); public abstract void rollback();} Copy codeThe code is as follows: public class JdbcTemplateImpl extends org.springframework.jdbc.core.JdbcTemplate implements JdbcTemplate {  private PlatformTransactionManager platformTransactionManager; private DefaultTransactionDefinition transactionDefinition; private ThreadLocal<TransactionStatus> transcationStatus = new ThreadLocal<TransactionStatus>();  public void beginTranstaion() {  TransactionStatus tmp = platformTransactionManager.getTransaction(transactionDefinition);  transcationStatus.set(tmp); }  public […]