Package org.springframework.jdbc.datasource

Examples of org.springframework.jdbc.datasource.DataSourceTransactionManager


  }
 
  @Bean
  public PlatformTransactionManager transactionManager()
  {
    return new DataSourceTransactionManager(dataSource);
  }
View Full Code Here


  private void doExecuteScript(final Resource scriptResource) {
    if (scriptResource == null || !scriptResource.exists()) {
      throw new IllegalArgumentException("Script resource is null or does not exist");
    }

    TransactionTemplate transactionTemplate = new TransactionTemplate(new DataSourceTransactionManager(dataSource));
    transactionTemplate.execute(new TransactionCallback<Void>() {

      @Override
      public Void doInTransaction(TransactionStatus status) {
        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
View Full Code Here

    final SkipWriterStub<String> writer = new SkipWriterStub<String>();
    FaultTolerantStepFactoryBean<String, String> factory = new FaultTolerantStepFactoryBean<String, String>();
    factory.setItemWriter(writer);

    @SuppressWarnings("serial")
    DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(dataSource) {
      private boolean failed = false;
      @Override
      protected void doCommit(DefaultTransactionStatus status) throws TransactionException {
        if (writer.getWritten().isEmpty() || failed || !isExistingTransaction(status.getTransaction())) {
          super.doCommit(status);
View Full Code Here

    when(con.prepareStatement("select foo from bar", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY,
        ResultSet.HOLD_CURSORS_OVER_COMMIT)).thenReturn(ps);
    when(ds.getConnection()).thenReturn(con);
    when(ds.getConnection()).thenReturn(con);
    con.commit();
    PlatformTransactionManager tm = new DataSourceTransactionManager(ds);
    TransactionTemplate tt = new TransactionTemplate(tm);
    final JdbcCursorItemReader<String> reader = new JdbcCursorItemReader<String>();
    reader.setDataSource(new ExtendedConnectionDataSourceProxy(ds));
    reader.setUseSharedExtendedConnection(true);
    reader.setSql("select foo from bar");
View Full Code Here

    PreparedStatement ps = mock(PreparedStatement.class);
    when(con.prepareStatement("select foo from bar", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)).thenReturn(ps);
    when(ds.getConnection()).thenReturn(con);
    when(ds.getConnection()).thenReturn(con);
    con.commit();
    PlatformTransactionManager tm = new DataSourceTransactionManager(ds);
    TransactionTemplate tt = new TransactionTemplate(tm);
    final JdbcCursorItemReader<String> reader = new JdbcCursorItemReader<String>();
    reader.setDataSource(ds);
    reader.setSql("select foo from bar");
    final ExecutionContext ec = new ExecutionContext();
View Full Code Here

    con.close();


    final ExtendedConnectionDataSourceProxy csds = new ExtendedConnectionDataSourceProxy();
    csds.setDataSource(ds);
    PlatformTransactionManager tm = new DataSourceTransactionManager(csds);
    TransactionTemplate tt = new TransactionTemplate(tm);
    final TransactionTemplate tt2 = new TransactionTemplate(tm);
    tt2.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
    final JdbcTemplate template = new JdbcTemplate(csds);
View Full Code Here

  private JobExplorer jobExplorer;

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

  private void doExecuteScript(final Resource scriptResource) {
    if (scriptResource == null || !scriptResource.exists())
      return;
    final JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);

    TransactionTemplate transactionTemplate = new TransactionTemplate(new DataSourceTransactionManager(dataSource));
    transactionTemplate.execute(new TransactionCallback<Void>() {

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

    when(con.prepareCall("{call foo_bar()}", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY,
        ResultSet.HOLD_CURSORS_OVER_COMMIT)).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(new ExtendedConnectionDataSourceProxy(ds));
    reader.setUseSharedExtendedConnection(true);
    reader.setProcedureName("foo_bar");
View Full Code Here

    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");
    final ExecutionContext ec = new ExecutionContext();
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.