/** * Creates the appropriate ConnectionPool to use for this DataSource. * * @return appropriate ConnectionPool to use for this DataSource */ protected PGConnectionPoolDataSource createConnectionPool() { return new PGConnectionPoolDataSource(); }
/** * Initializes this DataSource. If the initialConnections is greater than zero, that number of * connections will be created. After this method is called, the DataSource properties cannot be * changed. If you do not call this explicitly, it will be called the first time you get a * connection from the DataSource. * * @throws SQLException Occurs when the initialConnections is greater than zero, but the * DataSource is not able to create enough physical connections. */ public void initialize() throws SQLException { synchronized (lock) { source = createConnectionPool(); try { source.initializeFrom(this); } catch (Exception e) { throw new PSQLException(GT.tr("Failed to setup DataSource."), PSQLState.UNEXPECTED_ERROR, e); } while (available.size() < initialConnections) { available.push(source.getPooledConnection()); } initialized = true; } }
/** * Gets a connection which may be pooled by the app server or middleware implementation of * DataSource. * * @throws java.sql.SQLException Occurs when the physical database connection cannot be * established. */ public PooledConnection getPooledConnection() throws SQLException { return new PGPooledConnection(getConnection(), defaultAutoCommit); }
if (dataSource != null) { try { return dataSource.getPooledConnection(); PGConnectionPoolDataSource dataSource = new PGConnectionPoolDataSource(); dataSource.setUrl(jdbcUrl); dataSource.setDefaultRowFetchSize(defaultFetchSize); dataSource.setConnectTimeout(timeout); dataSource.setLoginTimeout(timeout); dataSource.setSocketTimeout(timeout); PooledConnection connection = dataSource.getPooledConnection();
} else if (dbType.equals("postgres")) { dataSource = new PGConnectionPoolDataSource(); ((PGConnectionPoolDataSource) dataSource).setPortNumber(5432); ((PGConnectionPoolDataSource) dataSource).setUser("dtf11"); ((PGConnectionPoolDataSource) dataSource).setPassword("dtf11"); ((PGConnectionPoolDataSource) dataSource) .setServerName("tywin.eng.hst.ams2.redhat.com"); ((PGConnectionPoolDataSource) dataSource) .setDatabaseName("jbossts"); recoveryDataSource = new PGSimpleDataSource(); ((PGSimpleDataSource) recoveryDataSource).setPortNumber(5432);
pc = source.getPooledConnection(); used.push(pc); break;
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { readBaseObject(in); defaultAutoCommit = in.readBoolean(); } }
/** * @see org.postgresql.ds.common.BaseDataSource#setLoginTimeout(java.lang.String) */ public void setLoginTimeout(int s) throws SQLException { connectionPoolDataSource.setLoginTimeout(s); }
/** * Set the user password credential establish the connection. This value is * used if no connection information is supplied by the application when * attempting to create a connection. * * @param password the password credential used to establish the connection; may * be null */ public void setPassword(String password) { connectionPoolDataSource.setPassword(password); }
/** * Set the database name. * * @param databaseName the database name */ public void setDatabaseName(String databaseName) { connectionPoolDataSource.setDatabaseName(databaseName); }
if (dataSource != null) { try { return dataSource.getPooledConnection(); PGConnectionPoolDataSource dataSource = new PGConnectionPoolDataSource(); dataSource.setUrl(jdbcUrl); dataSource.setDefaultRowFetchSize(defaultFetchSize); dataSource.setConnectTimeout(timeout); dataSource.setLoginTimeout(timeout); dataSource.setSocketTimeout(timeout); PooledConnection connection = dataSource.getPooledConnection();
pc = source.getPooledConnection(); used.push(pc); break;
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { readBaseObject(in); defaultAutoCommit = in.readBoolean(); } }
/** * Creates the appropriate ConnectionPool to use for this DataSource. */ protected PGConnectionPoolDataSource createConnectionPool() { return new PGConnectionPoolDataSource(); }
/** * Initializes this DataSource. If the initialConnections is greater than zero, * that number of connections will be created. After this method is called, * the DataSource properties cannot be changed. If you do not call this * explicitly, it will be called the first time you get a connection from the * DataSource. * @throws java.sql.SQLException * Occurs when the initialConnections is greater than zero, but the * DataSource is not able to create enough physical connections. */ public void initialize() throws SQLException { synchronized (lock ) { source = createConnectionPool(); try { source.initializeFrom(this); } catch (Exception e) { throw new PSQLException(GT.tr("Failed to setup DataSource."), PSQLState.UNEXPECTED_ERROR, e); } while (available.size() < initialConnections) { available.push(source.getPooledConnection()); } initialized = true; } }
pc = source.getPooledConnection(); used.push(pc); break;
/** * Gets a connection which may be pooled by the app server or middleware implementation of * DataSource. * * @throws java.sql.SQLException Occurs when the physical database connection cannot be * established. */ public PooledConnection getPooledConnection(String user, String password) throws SQLException { return new PGPooledConnection(getConnection(user, password), defaultAutoCommit); }
private Object loadConnectionPool(Reference ref) { PGConnectionPoolDataSource cp = new PGConnectionPoolDataSource(); return loadBaseDataSource(cp, ref); }
/** * Initializes this DataSource. If the initialConnections is greater than zero, * that number of connections will be created. After this method is called, * the DataSource properties cannot be changed. If you do not call this * explicitly, it will be called the first time you get a connection from the * DataSource. * @throws java.sql.SQLException * Occurs when the initialConnections is greater than zero, but the * DataSource is not able to create enough physical connections. */ public void initialize() throws SQLException { synchronized (lock ) { source = createConnectionPool(); try { source.initializeFrom(this); } catch (Exception e) { throw new PSQLException(GT.tr("Failed to setup DataSource."), PSQLState.UNEXPECTED_ERROR, e); } while (available.size() < initialConnections) { available.push(source.getPooledConnection()); } initialized = true; } }
pc = source.getPooledConnection(); used.push(pc); break;