@Override protected boolean isExistingTransaction(Object transaction) { DataSourceTransactionObject txObject = (DataSourceTransactionObject) transaction; return (txObject.hasConnectionHolder() && txObject.getConnectionHolder().isTransactionActive()); }
@Override public boolean isRollbackOnly() { return getConnectionHolder().isRollbackOnly(); }
public void setRollbackOnly() { getConnectionHolder().setRollbackOnly(); }
@Override protected void doAfterCompletion(int status) { super.doAfterCompletion(status); Connection con = DataSourceUtils.getConnection(ds2); DataSourceUtils.releaseConnection(con, ds2); } };
/** * Create a new DriverManagerDataSource with the given JDBC URL, * not specifying a username or password for JDBC access. * @param url the JDBC URL to use for accessing the DriverManager * @param conProps the JDBC connection properties * @see java.sql.DriverManager#getConnection(String) */ public DriverManagerDataSource(String url, Properties conProps) { setUrl(url); setConnectionProperties(conProps); }
/** * Create a new DriverManagerDataSource with the given JDBC URL, * not specifying a username or password for JDBC access. * @param url the JDBC URL to use for accessing the DriverManager * @see java.sql.DriverManager#getConnection(String) */ public DriverManagerDataSource(String url) { setUrl(url); }
/** * Create a new DataSourceTransactionManager instance. * @param dataSource the JDBC DataSource to manage transactions for */ public DataSourceTransactionManager(DataSource dataSource) { this(); setDataSource(dataSource); afterPropertiesSet(); }
/** * Create a new DriverManagerDataSource with the given standard Driver parameters. * @param driver the JDBC Driver object * @param url the JDBC URL to use for accessing the DriverManager * @param conProps the JDBC connection properties * @see java.sql.Driver#connect(String, java.util.Properties) */ public SimpleDriverDataSource(Driver driver, String url, Properties conProps) { setDriver(driver); setUrl(url); setConnectionProperties(conProps); }
/** * Create a new DriverManagerDataSource with the given standard Driver parameters. * @param driver the JDBC Driver object * @param url the JDBC URL to use for accessing the DriverManager * @see java.sql.Driver#connect(String, java.util.Properties) */ public SimpleDriverDataSource(Driver driver, String url) { setDriver(driver); setUrl(url); }
@Override public Connection getConnection() throws SQLException { // Return a transactional Connection, if any. return DataSourceUtils.doGetConnection(dataSource); } @Override
/** * This implementation delegates to {@code getConnectionFromDriver}, * using the default username and password of this DataSource. * @see #getConnectionFromDriver(String, String) * @see #setUsername * @see #setPassword */ @Override public Connection getConnection() throws SQLException { return getConnectionFromDriver(getUsername(), getPassword()); }
/** * Create a new LazyConnectionDataSourceProxy. * @param targetDataSource the target DataSource */ public LazyConnectionDataSourceProxy(DataSource targetDataSource) { setTargetDataSource(targetDataSource); afterPropertiesSet(); }
@Override public void setPassword(String password) { dataSource.setPassword(password); } };
/** * Create a new DelegatingDataSource. * @param targetDataSource the target DataSource */ public DelegatingDataSource(DataSource targetDataSource) { setTargetDataSource(targetDataSource); }
/** * Create a new ConnectionHolder for the given JDBC Connection, * wrapping it with a {@link SimpleConnectionHandle}, * assuming that there is no ongoing transaction. * @param connection the JDBC Connection to hold * @see SimpleConnectionHandle * @see #ConnectionHolder(java.sql.Connection, boolean) */ public ConnectionHolder(Connection connection) { this.connectionHandle = new SimpleConnectionHandle(connection); }
/** * Close the underlying Connection. * The provider of this DataSource needs to care for proper shutdown. * <p>As this bean implements DisposableBean, a bean factory will * automatically invoke this on destruction of its cached singletons. */ @Override public void destroy() { synchronized (this.connectionMonitor) { closeConnection(); } }
/** * Simply delegates to {@link #doGetConnection(String, String)}, * keeping the given user credentials as-is. */ @Override public Connection getConnection(String username, String password) throws SQLException { return doGetConnection(username, password); }
/** * Create a new DataSourceTransactionManager instance. * A DataSource has to be set to be able to use it. * @see #setDataSource */ public DataSourceTransactionManager() { setNestedTransactionAllowed(true); }
/** * This implementation delegates to {@code getConnectionFromDriver}, * using the given username and password. * @see #getConnectionFromDriver(String, String) */ @Override public Connection getConnection(String username, String password) throws SQLException { return getConnectionFromDriver(username, password); }
/** * Reset the underlying shared Connection, to be reinitialized on next access. */ public void resetConnection() { synchronized (this.connectionMonitor) { closeConnection(); this.target = null; this.connection = null; } }