Package org.springframework.jdbc.datasource

Examples of org.springframework.jdbc.datasource.DataSourceTransactionManager


    CallableStatement cs = mock(CallableStatement.class);
    when(con.prepareCall("{call foo_bar(?, ?)}", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)).thenReturn(cs);
    when(ds.getConnection()).thenReturn(con);
    when(ds.getConnection()).thenReturn(con);
    con.commit();
    PlatformTransactionManager tm = new DataSourceTransactionManager(ds);
    TransactionTemplate tt = new TransactionTemplate(tm);
    final StoredProcedureItemReader<String> reader = new StoredProcedureItemReader<String>();
    reader.setDataSource(ds);
    reader.setProcedureName("foo_bar");
    reader.setParameters(new SqlParameter[] {
View Full Code Here


  }

  private void doExecuteScript(final Resource scriptResource) {
    if (scriptResource == null || !scriptResource.exists())
      return;
    TransactionTemplate transactionTemplate = new TransactionTemplate(new DataSourceTransactionManager(dataSource));
    transactionTemplate.execute(new TransactionCallback<Void>() {

            @Override
      @SuppressWarnings("unchecked")
      public Void doInTransaction(TransactionStatus status) {
View Full Code Here

  }

  private void doExecuteScript(final Resource scriptResource) {
    if (scriptResource == null || !scriptResource.exists())
      return;
    TransactionTemplate transactionTemplate = new TransactionTemplate(new DataSourceTransactionManager(dataSource));
    transactionTemplate.execute(new TransactionCallback<Void>() {

      @Override
      @SuppressWarnings("unchecked")
      public Void doInTransaction(TransactionStatus status) {
View Full Code Here

    catch (IOException e) {
      throw new BeanInitializationException("Cannot load script from [" + scriptResource + "]", e);
    }
    for (int i = 0; i < scripts.length; i++) {
      final String script = scripts[i].trim();
      TransactionTemplate transactionTemplate = new TransactionTemplate(new DataSourceTransactionManager(
          dataSource));
      transactionTemplate.execute(new TransactionCallback<Void>() {

        @Override
        public Void doInTransaction(TransactionStatus status) {
View Full Code Here

  public static final String DEFAULT_ISOLATION_LEVEL = "ISOLATION_SERIALIZABLE";

  @Autowired(required = true)
  public void setDataSource(DataSource dataSource) {
    this.dataSource = dataSource;
    this.transactionManager = new DataSourceTransactionManager(dataSource);
  }
View Full Code Here

   */
  public void startTransaction() {
    try {
      DBEnvironment environment = DBEnvironmentFactory.getCurrentDBEnvironment();
      DataSource dataSource = environment.getDataSource(true);
      PlatformTransactionManager platformTransactionManager = new DataSourceTransactionManager(dataSource);

      setTransaction(platformTransactionManager);
    } catch (UnConfigDataBaseTypeException e) {
      setTransaction(null);
    }
View Full Code Here

  /**
   * 测试是否已经存在事务,如果已经有事务,则抛出异常<br>
   * 用来debug用函数
   */
  public final static void testIfHasTransactional() {
    PlatformTransactionManager platformTransactionManager = new DataSourceTransactionManager(DBEnvironmentFactory
        .getCurrentDBEnvironment().getDataSource(false));
    TransactionStatus status = platformTransactionManager.getTransaction(new DefaultTransactionDefinition(
        TransactionDefinition.PROPAGATION_NEVER));
    platformTransactionManager.commit(status);
  }
View Full Code Here

  /**
   * 强行终止spring事务,如果已经存在
   */
  public final static void forceEndTransactional() {
    PlatformTransactionManager platformTransactionManager = new DataSourceTransactionManager(DBEnvironmentFactory
        .getCurrentDBEnvironment().getDataSource(false));
    TransactionStatus status = platformTransactionManager.getTransaction(new DefaultTransactionDefinition(
        TransactionDefinition.PROPAGATION_REQUIRED));
    platformTransactionManager.rollback(status);
  }
View Full Code Here

    return ds;
  }

  @Bean(name = "transactionManager")
  public PlatformTransactionManager annotationDrivenTransactionManager() {
    DataSourceTransactionManager transactionManager = new DataSourceTransactionManager();
    transactionManager.setDataSource(dataSource());
    return transactionManager;
  }
View Full Code Here

    return ds;
  }

  @Bean(name = "transactionManager")
  public PlatformTransactionManager annotationDrivenTransactionManager() {
    DataSourceTransactionManager transactionManager = new DataSourceTransactionManager();
    transactionManager.setDataSource(dataSource());
    return transactionManager;
  }
View Full Code Here

TOP

Related Classes of org.springframework.jdbc.datasource.DataSourceTransactionManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.