Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.biojava.utils
Class JDBCConnectionPool

    java.lang.Object
      org.biojava.utils.JDBCConnectionPool

    public class JDBCConnectionPool

extends Object

Really simple connection pool for JDBC databases.

## Use:

     JDBCConnectionPool pool = new JDBCConnectionPool(jdbcURL, userName, passwd);
     ...
     Connection conn = pool.takeConnection();
     // do stuff with conn
     pool.putConnection(conn);
     // don't use conn from here on

     Statement stmt = pool.takeStatement();
     // do stuff with stmt
     pool.putStatement(stmt);
     // don't do anything else with stmt

It is not a good idea to call `close()` on a connection you get from a pool. This would prevent it from being re-used. Also, we have seen some odd behavior with connections involved in transactions being re-used. We have not yet identified exactly how you can safely use a pooled connection for transaction-safe code.

Note: We should probably be moving to a propper connection pool API. Let's standardise on one soon.

Author:
  Thomas Down, Matthew Pocock

Constructor Summary
`JDBCConnectionPool(String url)`
`JDBCConnectionPool(String url, String user, String pass)`

Method Summary
`void` | `putConnection(Connection c)`
`void` | `putStatement(Statement st)`
`Connection` | `takeConnection()`
`Statement` | `takeStatement()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### JDBCConnectionPool

    public JDBCConnectionPool(String url,
                              String user,
                              String pass)

### JDBCConnectionPool

    public JDBCConnectionPool(String url)

Method Detail

### takeConnection

    public Connection takeConnection()
                              throws SQLException

  Throws:
    `SQLException`

### putConnection

    public void putConnection(Connection c)
                       throws SQLException

  Throws:
    `SQLException`

### takeStatement

    public Statement takeStatement()
                            throws SQLException

  Throws:
    `SQLException`

### putStatement

    public void putStatement(Statement st)
                      throws SQLException

  Throws:
    `SQLException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD