use of javax.sql.ConnectionPoolDataSource in project derby by apache.
the class cdsXid method timeoutTestDerby1144PooledDS.
/**
* Tests for DERBY-1144
*
* This test tests that holdability, autocomit, and transactionIsolation
* are reset on getConnection for PooledConnections obtaind from
* connectionPoolDataSources
*
* DERBY-1134 has been filed for more comprehensive testing of client
* connection state.
*
* @throws SQLException
*/
public void timeoutTestDerby1144PooledDS() throws SQLException {
PooledConnection pc1 = null;
// Test holdability
ConnectionPoolDataSource ds = J2EEDataSource.getConnectionPoolDataSource();
pc1 = ds.getPooledConnection();
assertPooledConnHoldability("PooledConnection", pc1);
pc1.close();
// Test autocommit
pc1 = ds.getPooledConnection();
assertPooledConnAutoCommit("PooledConnection", pc1);
pc1.close();
// Test pooled connection isolation
pc1 = ds.getPooledConnection();
assertPooledConnIso("PooledConnection", pc1);
pc1.close();
}
use of javax.sql.ConnectionPoolDataSource in project derby by apache.
the class cdsXid method testClientTraceFileDSConnectionAttribute.
/**
* Check that traceFile connection attribute functions correctly.
* tracefile was tested in checkDriver, but not for DataSources.
* tracefile= was used in datasourcepermissions_net, but that's
* incorrect syntax. Note that we're not checking the contents of
* the tracefile.
*
* Note also that this test cannot run against a remote server.
* <p>
* This is also a regression test for DERBY-4717.
*
* @throws SQLException
*/
public void testClientTraceFileDSConnectionAttribute() throws SQLException {
String traceFile;
// with ConnectionPoolDataSource
ConnectionPoolDataSource cpds = J2EEDataSource.getConnectionPoolDataSource();
traceFile = "trace3.out";
JDBCDataSource.setBeanProperty(cpds, "connectionAttributes", "traceFile=" + traceFile);
// DERBY-2468 - trace3.out does not get created
((PooledConnection) getPhysicalConnection(cpds)).close();
JDBCDataSource.clearStringBeanProperty(cpds, "connectionAttributes");
traceFile = "trace4.out";
JDBCDataSource.setBeanProperty(cpds, "traceFile", traceFile);
((PooledConnection) getPhysicalConnection(cpds)).close();
cpds = null;
// now with XADataSource
XADataSource xads = J2EEDataSource.getXADataSource();
traceFile = "trace5.out";
JDBCDataSource.setBeanProperty(xads, "connectionAttributes", "traceFile=" + traceFile);
((XAConnection) getPhysicalConnection(xads)).close();
// DERBY-2468 - trace5.out does not get created
JDBCDataSource.clearStringBeanProperty(xads, "connectionAttributes");
traceFile = "trace6.out";
JDBCDataSource.setBeanProperty(xads, "traceFile", traceFile);
((XAConnection) getPhysicalConnection(xads)).close();
assertTraceFilesExistAndCanBeDeleted();
}
use of javax.sql.ConnectionPoolDataSource in project derby by apache.
the class PoolDSAuthenticationTest method assertConnectionOK.
protected void assertConnectionOK(String dbName, String user, String password) throws SQLException {
ConnectionPoolDataSource pds = J2EEDataSource.getConnectionPoolDataSource();
JDBCDataSource.setBeanProperty(pds, "databaseName", dbName);
pds.getPooledConnection(user, password).close();
}
use of javax.sql.ConnectionPoolDataSource in project derby by apache.
the class PoolDSAuthenticationTest method assertShutdownWOUPOK.
protected void assertShutdownWOUPOK(String dbName, String user, String password) throws SQLException {
ConnectionPoolDataSource pds = J2EEDataSource.getConnectionPoolDataSource();
JDBCDataSource.setBeanProperty(pds, "databaseName", dbName);
JDBCDataSource.setBeanProperty(pds, "user", user);
JDBCDataSource.setBeanProperty(pds, "password", password);
JDBCDataSource.setBeanProperty(pds, "shutdownDatabase", "shutdown");
try {
pds.getPooledConnection();
fail("expected a failed shutdown connection");
} catch (SQLException e) {
// expect 08006 on successful shutdown
assertSQLState("08006", e);
}
}
use of javax.sql.ConnectionPoolDataSource in project derby by apache.
the class PoolDSAuthenticationTest method assertSystemShutdownOK.
// using an empty dbName is interpreted as system shutdown
protected void assertSystemShutdownOK(String dbName, String user, String password) throws SQLException {
ConnectionPoolDataSource pds = J2EEDataSource.getConnectionPoolDataSource();
JDBCDataSource.clearStringBeanProperty(pds, "databaseName");
JDBCDataSource.setBeanProperty(pds, "shutdownDatabase", "shutdown");
JDBCDataSource.setBeanProperty(pds, "databaseName", dbName);
JDBCDataSource.setBeanProperty(pds, "user", user);
JDBCDataSource.setBeanProperty(pds, "password", password);
try {
pds.getPooledConnection();
fail("expected system shutdown resulting in XJ015 error");
} catch (SQLException e) {
// expect XJ015, system shutdown, on successful shutdown
assertSQLState("XJ015", e);
}
}
Aggregations