Example usage for org.springframework.jdbc.datasource DataSourceTransactionManager getDataSource

List of usage examples for org.springframework.jdbc.datasource DataSourceTransactionManager getDataSource

Introduction

In this page you can find the example usage for org.springframework.jdbc.datasource DataSourceTransactionManager getDataSource.

Prototype

@Nullable
public DataSource getDataSource() 

Source Link

Document

Return the JDBC DataSource that this instance manages transactions for.

Usage

From source file:com.px100systems.data.plugin.persistence.jdbc.TransactionalJdbcService.java

/**
 * Spring transaction manager with configured DataSource, etc.
 * @param mgr transaction manager//  w w  w . j a v  a2s. c  om
 */
@Required
public void setTransactionManager(DataSourceTransactionManager mgr) {
    transaction = new TransactionTemplate(mgr);
    transaction.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
    transaction.setTimeout(300);
    jdbc = new JdbcTemplate(mgr.getDataSource());
    try {
        mgr.getDataSource().getConnection().close();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:work.db.CustomJDBCAppender.java

@Override
protected java.sql.Connection getConnection() throws java.sql.SQLException {

    if (connection == null) {
        org.springframework.jdbc.datasource.DataSourceTransactionManager dstm = (org.springframework.jdbc.datasource.DataSourceTransactionManager) ExternalBeanFactory
                .getBean("txManager");
        if (dstm == null)
            throw new java.sql.SQLException("dstm is null");
        System.out.println("here");
        connection = DataSourceUtils.getConnection(dstm.getDataSource());
        return connection;
    } else {/*from   w  w w.j  av  a  2s.  c o  m*/
        return connection;
    }
}

From source file:org.geowebcache.diskquota.jdbc.JDBCQuotaStore.java

/**
 * Sets the connection pool provider and initializes the tables in the dbms if missing
 *//*from  ww  w .jav  a 2s  . c  o m*/
public void setDataSource(DataSource dataSource) {
    this.dataSource = dataSource;
    DataSourceTransactionManager dsTransactionManager = new DataSourceTransactionManager(dataSource);
    this.tt = new TransactionTemplate(dsTransactionManager);
    this.jt = new SimpleJdbcTemplate(dsTransactionManager.getDataSource());
}