use of org.postgresql.jdbc2.optional.ConnectionPool in project pgjdbc by pgjdbc.
the class PGDataSourceFactory method createConnectionPoolDataSource.
public ConnectionPoolDataSource createConnectionPoolDataSource(Properties props) throws SQLException {
props = new SingleUseProperties(props);
ConnectionPool dataSource = new ConnectionPool();
configureBaseDataSource(dataSource, props);
return dataSource;
}
use of org.postgresql.jdbc2.optional.ConnectionPool in project pgjdbc by pgjdbc.
the class ConnectionPoolTest method initializeDataSource.
/**
* Creates and configures a ConnectionPool.
*/
@Override
protected void initializeDataSource() {
if (bds == null) {
bds = new ConnectionPool();
setupDataSource(bds);
}
}
use of org.postgresql.jdbc2.optional.ConnectionPool in project pgjdbc by pgjdbc.
the class ConnectionPoolTest method testSerializable.
@Test
public void testSerializable() throws IOException, ClassNotFoundException {
ConnectionPool pool = new ConnectionPool();
pool.setDefaultAutoCommit(false);
pool.setServerName("db.myhost.com");
pool.setDatabaseName("mydb");
pool.setUser("user");
pool.setPassword("pass");
pool.setPortNumber(1111);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(pool);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
ConnectionPool pool2 = (ConnectionPool) ois.readObject();
assertEquals(pool.isDefaultAutoCommit(), pool2.isDefaultAutoCommit());
assertEquals(pool.getServerName(), pool2.getServerName());
assertEquals(pool.getDatabaseName(), pool2.getDatabaseName());
assertEquals(pool.getUser(), pool2.getUser());
assertEquals(pool.getPassword(), pool2.getPassword());
assertEquals(pool.getPortNumber(), pool2.getPortNumber());
}
use of org.postgresql.jdbc2.optional.ConnectionPool in project pgjdbc by pgjdbc.
the class PGDataSourceFactoryTest method testCreateConnectionPoolDataSourceConfigured.
@Test
public void testCreateConnectionPoolDataSourceConfigured() throws Exception {
Properties properties = new Properties();
properties.put(DataSourceFactory.JDBC_DATABASE_NAME, "db");
ConnectionPoolDataSource dataSource = dataSourceFactory.createConnectionPoolDataSource(properties);
Assert.assertNotNull(dataSource);
Assert.assertTrue(dataSource instanceof ConnectionPool);
ConnectionPool connectionPoolDataSource = (ConnectionPool) dataSource;
Assert.assertEquals("db", connectionPoolDataSource.getDatabaseName());
}
use of org.postgresql.jdbc2.optional.ConnectionPool in project openGauss-connector-jdbc by opengauss-mirror.
the class ConnectionPoolTest method testSerializable.
@Test
public void testSerializable() throws IOException, ClassNotFoundException {
ConnectionPool pool = new ConnectionPool();
pool.setDefaultAutoCommit(false);
pool.setServerName("db.myhost.com");
pool.setDatabaseName("mydb");
pool.setUser("user");
pool.setPassword("pass");
pool.setPortNumber(1111);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(pool);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
ConnectionPool pool2 = (ConnectionPool) ois.readObject();
assertEquals(pool.isDefaultAutoCommit(), pool2.isDefaultAutoCommit());
assertEquals(pool.getServerName(), pool2.getServerName());
assertEquals(pool.getDatabaseName(), pool2.getDatabaseName());
assertEquals(pool.getUser(), pool2.getUser());
assertEquals(pool.getPassword(), pool2.getPassword());
assertEquals(pool.getPortNumber(), pool2.getPortNumber());
}
Aggregations