use of javax.sql.ConnectionPoolDataSource in project derby by apache.
the class PoolDSAuthenticationTest method assertShutdownWOUPFail.
protected void assertShutdownWOUPFail(String expectedSqlState, String dbName, String user, String password) throws SQLException {
ConnectionPoolDataSource pds = J2EEDataSource.getConnectionPoolDataSource();
JDBCDataSource.setBeanProperty(pds, "shutdownDatabase", "shutdown");
JDBCDataSource.setBeanProperty(pds, "user", user);
JDBCDataSource.setBeanProperty(pds, "password", password);
JDBCDataSource.setBeanProperty(pds, "databaseName", dbName);
try {
pds.getPooledConnection();
fail("expected failed shutdown");
} catch (SQLException e) {
assertSQLState(expectedSqlState, e);
}
}
use of javax.sql.ConnectionPoolDataSource in project derby by apache.
the class RolesTest method testCurrentRoleIsReset.
/**
* Verifies that the current role is reset when creating a new logical
* connection.
* <p>
* The test is run in a non-statement pooling configuration first,
* and then with statement pooling enabled if the environment supports it.
* <p>
* The test pattern is borrowed from the test case in J2EEDataSourceTest.
*
* @see org.apache.derbyTesting.functionTests.tests.jdbcapi.J2EEDataSourceTest#testSchemaIsReset
*
* @throws SQLException if something goes wrong
*/
private void testCurrentRoleIsReset() throws SQLException {
if (_authLevel == SQLAUTHORIZATION && isDbo()) /* once is enough */
{
final String user = "DonaldDuck";
final String passwd = user.concat(pwSuffix);
ConnectionPoolDataSource cpDs = J2EEDataSource.getConnectionPoolDataSource();
// Test without statement pooling first.
doTestCurrentRoleIsReset(cpDs.getPooledConnection(user, passwd), user);
// This is currently only implemented in the client driver.
if (usingDerbyNetClient()) {
J2EEDataSource.setBeanProperty(cpDs, "maxStatements", 7);
doTestCurrentRoleIsReset(cpDs.getPooledConnection(user, passwd), user);
}
}
}
use of javax.sql.ConnectionPoolDataSource in project derby by apache.
the class ConnectionPoolDataSourceConnector method singleUseDS.
/**
* Get a connection from a single use ConnectionPoolDataSource configured
* from the configuration but with the passed in property set.
*/
private ConnectionPoolDataSource singleUseDS(HashMap hm) throws SQLException {
ConnectionPoolDataSource sds = J2EEDataSource.getConnectionPoolDataSource(config, hm);
// Enable statement pooling by default for single-use data sources
// too, just like it's enabled for the default data source in
// setConfiguration().
enableStatementPooling(sds);
return sds;
}
use of javax.sql.ConnectionPoolDataSource in project derby by apache.
the class ConnectionPoolDataSourceConnector method shutEngine.
public void shutEngine(boolean deregisterDriver) throws SQLException {
if (SanityManager.DEBUG) {
// "false" only used with driver manager
SanityManager.ASSERT(deregisterDriver);
}
ConnectionPoolDataSource tmpDs = singleUseDS(DataSourceConnector.makeShutdownDBAttributes(config));
JDBCDataSource.setBeanProperty(tmpDs, "databaseName", "");
tmpDs.getPooledConnection();
}
use of javax.sql.ConnectionPoolDataSource in project derby by apache.
the class NSSecurityMechanismTest method assertSecMecWithConnPoolingOK.
/**
* Test a deferred connection reset. When connection pooling is done
* and connection is reset, the client sends EXCSAT,ACCSEC and followed
* by SECCHK and ACCRDB. Test if the security mechanism related information
* is correctly reset or not. This method was added to help simulate
* regression test for DERBY-1080. It is called from testDerby1080.
* @param user username
* @param password password for connection
* @param secmec security mechanism for datasource
* @throws Exception
*/
private void assertSecMecWithConnPoolingOK(String user, String password, Short secmec) throws Exception {
ConnectionPoolDataSource cpds = getCPDS(user, password);
// call setSecurityMechanism with secmec.
JDBCDataSource.setBeanProperty(cpds, "SecurityMechanism", secmec);
// simulate case when connection will be re-used by getting
// a connection, closing it and then the next call to
// getConnection will re-use the previous connection.
PooledConnection pc = cpds.getPooledConnection();
Connection conn = pc.getConnection();
conn.close();
conn = pc.getConnection();
assertConnectionOK(conn);
pc.close();
conn.close();
}
Aggregations