use of javax.sql.ConnectionPoolDataSource in project mssql-jdbc by Microsoft.
the class JDBC43Test method connectionPoolDataSourceTest.
/**
* Tests that we are throwing the unsupported exception for createPooledConnectionBuilder()
* @throws SQLException
* @throws TestAbortedException
* @since 1.9
*/
@Test
public void connectionPoolDataSourceTest() throws TestAbortedException, SQLException {
assumeTrue(Util.supportJDBC43(connection));
ConnectionPoolDataSource ds = new SQLServerConnectionPoolDataSource();
try {
superShardingKey = ds.createShardingKeyBuilder().subkey("EASTERN_REGION", JDBCType.VARCHAR).build();
} catch (SQLException e) {
assert (e.getMessage().contains("not implemented"));
}
try {
shardingKey = ds.createShardingKeyBuilder().subkey("PITTSBURGH_BRANCH", JDBCType.VARCHAR).build();
} catch (SQLException e) {
assert (e.getMessage().contains("not implemented"));
}
try {
PooledConnection con = ds.createPooledConnectionBuilder().user("rafa").password("tennis").shardingKey(shardingKey).superShardingKey(superShardingKey).build();
} catch (SQLException e) {
assert (e.getMessage().contains("not implemented"));
}
}
use of javax.sql.ConnectionPoolDataSource in project derby by apache.
the class NSSecurityMechanismTest method getCPDS.
private javax.sql.ConnectionPoolDataSource getCPDS(String user, String password) {
HashMap<String, Object> attrs = new HashMap<String, Object>();
if (user != null)
attrs.put("user", user);
if (password != null)
attrs.put("password", password);
attrs = addRequiredAttributes(attrs);
ConnectionPoolDataSource cpds = J2EEDataSource.getConnectionPoolDataSource();
for (String property : attrs.keySet()) {
Object value = attrs.get(property);
JDBCDataSource.setBeanProperty(cpds, property, value);
}
return cpds;
}
use of javax.sql.ConnectionPoolDataSource in project derby by apache.
the class DataSourcePropertiesTest method embeddedTestAttributesAsPasswordWithoutPassword_pooled.
/**
* Tests that the default password is not sent as an attribute string when
* <code>attributesAsPassword</code> is <code>true</code>. The test is run
* with a <code>ConnectionPoolDataSource</code>.
*/
public void embeddedTestAttributesAsPasswordWithoutPassword_pooled() throws Exception {
ConnectionPoolDataSource ds = J2EEDataSource.getConnectionPoolDataSource();
JDBCDataSource.setBeanProperty(ds, "password", "mypassword");
JDBCDataSource.setBeanProperty(ds, "attributesAsPassword", Boolean.TRUE);
// DERBY-1586 caused a malformed url error here
PooledConnection pc = ds.getPooledConnection();
Connection c = pc.getConnection();
c.close();
}
use of javax.sql.ConnectionPoolDataSource in project derby by apache.
the class VerifySignatures method collectClassesFromConnectionPoolDataSource.
/**
* Obtain a connection from a <code>ConnectionPoolDataSource</code>
* object and perform JDBC operations on it. Collect the classes
* of all JDBC objects that are found.
*
* @param classes set into which classes are collected
* @exception SQLException if a database error occurs
*/
private static void collectClassesFromConnectionPoolDataSource(Set<ClassInfo> classes) throws SQLException {
ConnectionPoolDataSource cpds = J2EEDataSource.getConnectionPoolDataSource();
addClass(classes, cpds.getClass(), javax.sql.ConnectionPoolDataSource.class);
PooledConnection pc = cpds.getPooledConnection(TestConfiguration.getCurrent().getUserName(), TestConfiguration.getCurrent().getUserPassword());
addClass(classes, pc.getClass(), javax.sql.PooledConnection.class);
collectClassesFromConnection(pc.getConnection(), classes);
pc.close();
}
use of javax.sql.ConnectionPoolDataSource in project derby by apache.
the class cdsXid method testJira95pds.
// test jira-derby 95 - a NullPointerException was returned when passing
// an incorrect database name, should now give error XCY00
// with ConnectionPoolDataSource
public void testJira95pds() throws Exception {
try {
ConnectionPoolDataSource pds = J2EEDataSource.getConnectionPoolDataSource();
JDBCDataSource.setBeanProperty(pds, "databaseName", "jdbc:derby:boo");
pds.getPooledConnection();
fail("expected an SQLException!");
} catch (SQLException sqle) {
assertSQLState("XCY00", sqle);
} catch (Exception e) {
throw e;
}
}
Aggregations