com.vaadin.data.util.sqlcontainer.connection.


Class SimpleJDBCConnectionPool

java.lang.Object
  com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool

All Implemented Interfaces:

JDBCConnectionPool, Serializable

public class SimpleJDBCConnectionPool
extends Object
implements JDBCConnectionPool

Simple implementation of the JDBCConnectionPool interface. Handles loading the JDBC driver, setting up the connections and ensuring they are still usable upon release.

See Also:

Serialized Form

Constructor Summary
SimpleJDBCConnectionPool(String driverName, String connectionUri, String userName, String password)
           
SimpleJDBCConnectionPool(String driverName, String connectionUri, String userName, String password, int initialConnections, int maxConnections)
           
 
Method Summary
 void destroy()
          Destroys the connection pool: close() is called an all the connections in the pool, whether available or reserved.
 void releaseConnection(Connection conn)
          Releases a connection that was retrieved earlier.
 Connection reserveConnection()
          Retrieves a connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleJDBCConnectionPool

public SimpleJDBCConnectionPool(String driverName,
                                String connectionUri,
                                String userName,
                                String password)
                         throws SQLException

Throws:

SQLException

SimpleJDBCConnectionPool

public SimpleJDBCConnectionPool(String driverName,
                                String connectionUri,
                                String userName,
                                String password,
                                int initialConnections,
                                int maxConnections)
                         throws SQLException

Throws:

SQLException

Method Detail

reserveConnection

public Connection reserveConnection()
                             throws SQLException

Description copied from interface: JDBCConnectionPool

Retrieves a connection.

Specified by:
reserveConnection in interface JDBCConnectionPool

Returns:
a usable connection to the database
Throws:
SQLException

releaseConnection

public void releaseConnection(Connection conn)

Description copied from interface: JDBCConnectionPool

Releases a connection that was retrieved earlier. Note that depending on implementation, the transaction possibly open in the connection may or may not be rolled back.

Specified by:
releaseConnection in interface JDBCConnectionPool

Parameters:
conn - Connection to be released

destroy

public void destroy()

Description copied from interface: JDBCConnectionPool

Destroys the connection pool: close() is called an all the connections in the pool, whether available or reserved. This method was added to fix PostgreSQL -related issues with connections that were left hanging 'idle'.

Specified by:
destroy in interface JDBCConnectionPool