public synchronized void closePool(String name) throws SQLException { ObjectPool pool = (ObjectPool) _pools.get(name); if (pool != null) { _pools.remove(name); try { pool.close(); } catch (Exception e) { throw new SQLNestedException("Error closing pool " + name, e); } } }
/** * Create or obtain a {@link PreparedStatement} from my pool. * @return a {@link PoolablePreparedStatement} */ public PreparedStatement prepareStatement(String sql) throws SQLException { try { return(PreparedStatement)(_pstmtPool.borrowObject(createKey(sql))); } catch(NoSuchElementException e) { throw new SQLNestedException("MaxOpenPreparedStatements limit reached", e); } catch(RuntimeException e) { throw e; } catch(Exception e) { throw new SQLNestedException("Borrow prepareStatement from pool failed", e); } }
/** * Create or obtain a {@link PreparedStatement} from my pool. * @return a {@link PoolablePreparedStatement} */ public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { try { return(PreparedStatement)(_pstmtPool.borrowObject(createKey(sql,resultSetType,resultSetConcurrency))); } catch(NoSuchElementException e) { throw new SQLNestedException("MaxOpenPreparedStatements limit reached", e); } catch(RuntimeException e) { throw e; } catch(Exception e) { throw new SQLNestedException("Borrow prepareStatement from pool failed", e); } }
/** * Sets the {*link ObjectPool} in which to pool {*link Connection}s. * @param pool the {*link ObjectPool} in which to pool those * {*link Connection}s */ public synchronized void setPool(ObjectPool pool) throws SQLException { if (null != _pool && pool != _pool) { try { _pool.close(); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new SQLNestedException("Cannot set the pool on this factory", e); } } _pool = pool; }
/** * Sets the {*link ObjectPool} in which to pool {*link Connection}s. * @param pool the {*link ObjectPool} in which to pool those {*link Connection}s */ synchronized public void setPool(KeyedObjectPool pool) throws SQLException { if (null != _pool && pool != _pool) { try { _pool.close(); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new SQLNestedException("Cannot set the pool on this factory", e); } } _pool = pool; }
/** * Create or obtain a {@link CallableStatement} from the pool. * @param sql the sql string used to define the CallableStatement * @return a {@link PoolableCallableStatement} * @throws SQLException * @since 1.3 */ public CallableStatement prepareCall(String sql) throws SQLException { try { return (CallableStatement) (_pstmtPool.borrowObject(createKey(sql, STATEMENT_CALLABLESTMT))); } catch (NoSuchElementException e) { throw new SQLNestedException("MaxOpenCallableStatements limit reached", e); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new SQLNestedException("Borrow callableStatement from pool failed", e); } }
/** * Create or obtain a {@link CallableStatement} from the pool. * @param sql the sql string used to define the CallableStatement * @return a {@link PoolableCallableStatement} * @throws SQLException * @since 1.3 */ public CallableStatement prepareCall(String sql) throws SQLException { try { return (CallableStatement) (_pstmtPool.borrowObject(createKey(sql, STATEMENT_CALLABLESTMT))); } catch (NoSuchElementException e) { throw new SQLNestedException("MaxOpenCallableStatements limit reached", e); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new SQLNestedException("Borrow callableStatement from pool failed", e); } }
PreparedStatement prepareStatement(String sql, String columnNames[]) throws SQLException { if (pstmtPool == null) { return connection.prepareStatement(sql, columnNames); } else { try { return (PreparedStatement) pstmtPool.borrowObject( createKey(sql, columnNames)); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new SQLNestedException("Borrow prepareStatement from pool failed", e); } } }
PreparedStatement prepareStatement(String sql, int columnIndexes[]) throws SQLException { if (pstmtPool == null) { return connection.prepareStatement(sql, columnIndexes); } else { try { return (PreparedStatement) pstmtPool.borrowObject( createKey(sql, columnIndexes)); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new SQLNestedException("Borrow prepareStatement from pool failed", e); } } }
PreparedStatement prepareStatement(String sql, int columnIndexes[]) throws SQLException { if (pstmtPool == null) { return connection.prepareStatement(sql, columnIndexes); } else { try { return (PreparedStatement) pstmtPool.borrowObject( createKey(sql, columnIndexes)); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new SQLNestedException("Borrow prepareStatement from pool failed", e); } } }
PreparedStatement prepareStatement(String sql, String columnNames[]) throws SQLException { if (pstmtPool == null) { return connection.prepareStatement(sql, columnNames); } else { try { return (PreparedStatement) pstmtPool.borrowObject( createKey(sql, columnNames)); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new SQLNestedException("Borrow prepareStatement from pool failed", e); } } }
/** * Create or obtain a {*link PreparedStatement} from my pool. * @return a {*link PoolablePreparedStatement} */ PreparedStatement prepareStatement(String sql) throws SQLException { if (pstmtPool == null) { return connection.prepareStatement(sql); } else { try { return (PreparedStatement) pstmtPool.borrowObject(createKey(sql)); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new SQLNestedException("Borrow prepareStatement from pool failed", e); } } }
/** * Return me to my pool. */ public void close() throws SQLException { if(isClosed()) { throw new SQLException("Already closed"); } else { try { _pool.returnObject(_key,this); } catch(SQLException e) { throw e; } catch(RuntimeException e) { throw e; } catch(Exception e) { throw new SQLNestedException("Cannot close preparedstatement (return to pool failed)", e); } } }
PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { if (pstmtPool == null) { return connection.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability); } else { try { return (PreparedStatement) pstmtPool.borrowObject( createKey(sql, resultSetType, resultSetConcurrency, resultSetHoldability)); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new SQLNestedException("Borrow prepareStatement from pool failed", e); } } }
PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { if (pstmtPool == null) { return connection.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability); } else { try { return (PreparedStatement) pstmtPool.borrowObject( createKey(sql, resultSetType, resultSetConcurrency, resultSetHoldability)); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new SQLNestedException("Borrow prepareStatement from pool failed", e); } } }
/** * Return me to my pool. */ public void close() throws SQLException { // calling close twice should have no effect if (!isClosed()) { try { _pool.returnObject(_key,this); } catch(SQLException e) { throw e; } catch(RuntimeException e) { throw e; } catch(Exception e) { throw new SQLNestedException("Cannot close preparedstatement (return to pool failed)", e); } } }
/** * Returns the CallableStatement to the pool. If {{@link #isClosed()}, this is a No-op. */ public void close() throws SQLException { // calling close twice should have no effect if (!isClosed()) { try { _pool.returnObject(_key,this); } catch(SQLException e) { throw e; } catch(RuntimeException e) { throw e; } catch(Exception e) { throw new SQLNestedException("Cannot close CallableStatement (return to pool failed)", e); } } }
/** * Returns the CallableStatement to the pool. If {{@link #isClosed()}, this is a No-op. */ public void close() throws SQLException { // calling close twice should have no effect if (!isClosed()) { try { _pool.returnObject(_key,this); } catch(SQLException e) { throw e; } catch(RuntimeException e) { throw e; } catch(Exception e) { throw new SQLNestedException("Cannot close CallableStatement (return to pool failed)", e); } } }
/** * Return me to my pool. */ public void close() throws SQLException { // calling close twice should have no effect if (!isClosed()) { try { _pool.returnObject(_key,this); } catch(SQLException e) { throw e; } catch(RuntimeException e) { throw e; } catch(Exception e) { throw new SQLNestedException("Cannot close preparedstatement (return to pool failed)", e); } } }
/** * Create or obtain a {@link PreparedStatement} from the pool. * @param sql the sql string used to define the PreparedStatement * @return a {@link PoolablePreparedStatement} */ public PreparedStatement prepareStatement(String sql) throws SQLException { if (null == _pstmtPool) { throw new SQLException( "Statement pool is null - closed or invalid PoolingConnection."); } try { return(PreparedStatement)(_pstmtPool.borrowObject(createKey(sql))); } catch(NoSuchElementException e) { throw (SQLException) new SQLException("MaxOpenPreparedStatements limit reached").initCause(e); } catch(RuntimeException e) { throw e; } catch(Exception e) { throw new SQLNestedException("Borrow prepareStatement from pool failed", e); } }