if (getDataSource(dataSourceName) != null) addDataSource(dataSourceName);
/** * 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; } }
/** * Gets a <b>non-pooled</b> connection, unless the user and password are the * same as the default values for this connection pool. * * @return A pooled connection. * @throws SQLException * Occurs when no pooled connection is available, and a new physical * connection cannot be created. */ public Connection getConnection(String user, String password) throws SQLException { // If this is for the default user/password, use a pooled connection if (user == null || (user.equals(getUser()) && ((password == null && getPassword() == null) || (password != null && password.equals(getPassword()))))) { return getConnection(); } // Otherwise, use a non-pooled connection if (!initialized) { initialize(); } return super.getConnection(user, password); }
/** * Gets a connection from the connection pool. * * @return A pooled connection. * @throws SQLException * Occurs when no pooled connection is available, and a new physical * connection cannot be created. */ public Connection getConnection() throws SQLException { if (!initialized) { initialize(); } return getPooledConnection(); }
/** * Gets a connection from the connection pool. * * @return A pooled connection. * @throws SQLException * Occurs when no pooled connection is available, and a new physical * connection cannot be created. */ public Connection getConnection() throws SQLException { if (!initialized) { initialize(); } return getPooledConnection(); }
/** * Gets a <b>non-pooled</b> connection, unless the user and password are the * same as the default values for this connection pool. * * @return A pooled connection. * @throws SQLException * Occurs when no pooled connection is available, and a new physical * connection cannot be created. */ public Connection getConnection(String user, String password) throws SQLException { // If this is for the default user/password, use a pooled connection if (user == null || (user.equals(getUser()) && ((password == null && getPassword() == null) || (password != null && password.equals(getPassword()))))) { return getConnection(); } // Otherwise, use a non-pooled connection if (!initialized) { initialize(); } return super.getConnection(user, password); }
/** * Gets a connection from the connection pool. * * @return A pooled connection. * @throws SQLException * Occurs when no pooled connection is available, and a new physical * connection cannot be created. */ public Connection getConnection() throws SQLException { if (!initialized) { initialize(); } return getPooledConnection(); }
if (getDataSource(dataSourceName) != null) addDataSource(dataSourceName);
/** * 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; } }
/** * Gets a <b>non-pooled</b> connection, unless the user and password are the * same as the default values for this connection pool. * * @return A pooled connection. * @throws SQLException * Occurs when no pooled connection is available, and a new physical * connection cannot be created. */ public Connection getConnection(String user, String password) throws SQLException { // If this is for the default user/password, use a pooled connection if (user == null || (user.equals(getUser()) && ((password == null && getPassword() == null) || (password != null && password.equals(getPassword()))))) { return getConnection(); } // Otherwise, use a non-pooled connection if (!initialized) { initialize(); } return super.getConnection(user, password); }
if (getDataSource(dataSourceName) != null) addDataSource(dataSourceName);
/** * 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; } }