use of org.apache.openejb.resource.jdbc.dbcp.BasicManagedDataSource in project tomee by apache.
the class DefaultDataSourceCreator method poolManaged.
@Override
public DataSource poolManaged(final String name, final String driver, final Properties properties) {
final BasicManagedDataSource ds = new BasicManagedDataSource(name);
ds.setDriverClassName(driver);
build(BasicManagedDataSource.class, ds, properties);
return ds;
}
use of org.apache.openejb.resource.jdbc.dbcp.BasicManagedDataSource in project tomee by apache.
the class DataSourceDefinitionGlobalJPATest method check.
private void check(final DataSource ds, final String name) throws SQLException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
// the first "cast part" is not important, we just want to check the jdbc url is ok
assertThat(ds, instanceOf(BasicManagedDataSource.class));
final BasicManagedDataSource dbcp = (BasicManagedDataSource) ds;
final Connection connection = dbcp.getConnection();
assertThat(connection, instanceOf(ManagedConnection.class));
final ManagedConnection mc = (ManagedConnection) connection;
final Method getInnermostDelegateInternal = DelegatingConnection.class.getDeclaredMethod("getInnermostDelegateInternal");
getInnermostDelegateInternal.setAccessible(true);
final Connection delegate = (Connection) getInnermostDelegateInternal.invoke(mc);
assertThat(delegate, instanceOf(JDBCConnection.class));
final Method getURL = JDBCConnection.class.getDeclaredMethod("getURL");
getURL.setAccessible(true);
assertEquals("jdbc:hsqldb:mem:" + name, getURL.invoke(delegate));
}
use of org.apache.openejb.resource.jdbc.dbcp.BasicManagedDataSource in project tomee by apache.
the class DefaultDataSourceCreator method poolManagedWithRecovery.
@Override
public DataSource poolManagedWithRecovery(final String name, final XAResourceWrapper xaResourceWrapper, final String driver, final Properties properties) {
final BasicManagedDataSource ds = new ManagedDataSourceWithRecovery(name, xaResourceWrapper);
ds.setDriverClassName(driver);
build(BasicManagedDataSource.class, ds, properties);
return ds;
}
use of org.apache.openejb.resource.jdbc.dbcp.BasicManagedDataSource in project tomee by apache.
the class UnenhancedTest method createJtaDataSource.
private DataSource createJtaDataSource(final TransactionManager transactionManager) throws Exception {
final BasicManagedDataSource ds = new BasicManagedDataSource(getClass().getName() + ".createJtaDs");
ds.setTransactionManager(transactionManager);
ds.setDriverClassName("org.hsqldb.jdbcDriver");
ds.setUrl("jdbc:hsqldb:mem:JpaTest");
ds.setUsername("sa");
ds.setPassword("");
ds.setMaxTotal(100);
ds.setMaxWait(10000);
ds.setTestOnBorrow(true);
return ds;
}
use of org.apache.openejb.resource.jdbc.dbcp.BasicManagedDataSource in project tomee by apache.
the class JpaTest method createJtaDataSource.
private DataSource createJtaDataSource(final TransactionManager transactionManager) throws Exception {
final BasicManagedDataSource ds = new BasicManagedDataSource(getClass().getName() + "createJtaDs");
ds.setTransactionManager(transactionManager);
ds.setDriverClassName("org.hsqldb.jdbcDriver");
ds.setUrl("jdbc:hsqldb:mem:JpaTest");
ds.setUsername("sa");
ds.setPassword("");
ds.setMaxTotal(100);
ds.setMaxWait(10000);
ds.setTestOnBorrow(true);
return ds;
}
Aggregations