PooledDataSource implements DataSourceEx, AutoCloseable { @Override public Connection getConnection() throws SQLException { Connection raw; try { raw = pool.get(); } catch (InterruptedException | ObjectBorrowException | ObjectCreationException ex) { throw new SQLException(ex); } catch (TimeoutException ex) { throw new SQLTimeoutException(ex); } return (Connection) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class<?>[]{Connection.class}, new PooledConnectionInvocationHandler(raw, pool)); } PooledDataSource(final int initialSize, final int maxSize,
          final String driverName, final String url, final String user, final String password);  PooledDataSource(final int initialSize, final int maxSize,
          final String driverName, final String url, final Properties properties, final int loginTimeoutSeconds);  PooledDataSource(final int initialSize, final int maxSize,
          final RecyclingSupplier.Factory<Connection> jdbcConnectionFactory); @Override Connection getConnection(); @Override Connection getConnection(final long timeout, final TimeUnit unit); @Override Connection getConnection(final String username, final String password); @Override PrintWriter getLogWriter(); @Override void setLogWriter(final PrintWriter out); @Override void setLoginTimeout(final int seconds); @Override int getLoginTimeout(); @Override T unwrap(final Class<T> iface); @Override boolean isWrapperFor(final Class<?> iface); @Override Logger getParentLogger(); @Override String toString(); @Override void close();  }
@Test public void testConnectionPool() throws SQLException, ObjectCreationException, IOException { Server server = Server.createTcpServer(new String[]{"-tcpPort", "9123", "-tcpAllowOthers"}).start(); try { File tempDB = File.createTempFile("test", "h2db"); String connStr = "jdbc:h2:tcp: PooledDataSource pds = new PooledDataSource(1, 2, new JdbcConnectionFactory("org.h2.Driver", connStr, "sa", "sa")); try (Connection conn = pds.getConnection()) { Assert.assertTrue(conn.isValid(10)); } } finally { server.stop(); } }