private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { readBaseObject(in); } }
private void writeObject(ObjectOutputStream out) throws IOException { writeBaseObject(out); }
/** * 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); }
fireConnectionFatalError(sqlException); throw sqlException; last.close(); if (!con.getAutoCommit()) fireConnectionFatalError(sqlException); throw (SQLException)sqlException.fillInStackTrace(); ConnectionHandler handler = new ConnectionHandler(con); last = handler; last.setProxy(proxyCon); return proxyCon;
/** * Fires a connection error event, but only if we * think the exception is fatal. * * @param e the SQLException to consider */ private void fireConnectionError(SQLException e) { if (!isFatalState(e.getSQLState())) return; fireConnectionFatalError(e); }
if (getDataSource(dataSourceName) != null) addDataSource(dataSourceName);
this.proxy = null; last = null; fireConnectionClosed(); if (ex != null) return Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Statement.class, org.postgresql.PGStatement.class}, new StatementHandler(this, st)); return Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{CallableStatement.class, org.postgresql.PGStatement.class}, new StatementHandler(this, st)); return Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{PreparedStatement.class, org.postgresql.PGStatement.class}, new StatementHandler(this, st));
/** * Used to fire a connection closed event to all listeners. */ void fireConnectionClosed() { ConnectionEvent evt = null; // Copy the listener list so the listener can remove itself during this method call ConnectionEventListener[] local = (ConnectionEventListener[]) listeners.toArray(new ConnectionEventListener[listeners.size()]); for (int i = 0; i < local.length; i++) { ConnectionEventListener listener = local[i]; if (evt == null) { evt = createConnectionEvent(null); } listener.connectionClosed(evt); } }
/** * Closes the physical database connection represented by this * PooledConnection. If any client has a connection based on * this PooledConnection, it is forcibly closed as well. */ public void close() throws SQLException { if (last != null) { last.close(); if (!con.getAutoCommit()) { try { con.rollback(); } catch (SQLException e) { } } } try { con.close(); } finally { con = null; } }
/** * 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 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); }
private void writeObject(ObjectOutputStream out) throws IOException { writeBaseObject(out); out.writeBoolean(defaultAutoCommit); }
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { readBaseObject(in); defaultAutoCommit = in.readBoolean(); }
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { readBaseObject(in); } }
/** * Used to fire a connection error event to all listeners. */ void fireConnectionFatalError(SQLException e) { ConnectionEvent evt = null; // Copy the listener list so the listener can remove itself during this method call ConnectionEventListener[] local = (ConnectionEventListener[])listeners.toArray(new ConnectionEventListener[listeners.size()]); for (int i = 0; i < local.length; i++) { ConnectionEventListener listener = local[i]; if (evt == null) { evt = createConnectionEvent(e); } listener.connectionErrorOccurred(evt); } }
/** * 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 void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { readBaseObject(in); } }