org.mentawai.db
Interface ConnectionHandler

All Superinterfaces:
org.mentacontainer.Factory, org.mentacontainer.Interceptor<Connection>
All Known Implementing Classes:
AbstractConnectionHandler, BoneCPConnectionHandler, C3P0ConnectionHandler, DataSourceConnectionHandler, DBCPConnectionHandler, JdbcConnectionHandler, JNDIConnectionHandler, MySQLBoneCPConnectionHandler

public interface ConnectionHandler
extends org.mentacontainer.Factory, org.mentacontainer.Interceptor<Connection>

This interface describes the behaviour of a Mentawai database connection provider. Classes implementing this interface may or may not use an underlying connection pool. This is a transparent way to get a connection to a database with Mentawai.

Author:
Sergio Oliveira

Nested Class Summary
static interface ConnectionHandler.Exec
           
 
Method Summary
 void destroy()
          Destroy the connection pool, closing and cleaning all connections.
 void exec(ConnectionHandler.Exec exec)
           
 Connection getConnection()
          Returns a Connection to the database.
 String getStatus()
          Print the status of this connection pool if any.
 void release(Connection conn)
          Release this connection.
 
Methods inherited from interface org.mentacontainer.Factory
getInstance, getType
 
Methods inherited from interface org.mentacontainer.Interceptor
onCleared, onCreated
 

Method Detail

getConnection

Connection getConnection()
                         throws SQLException
Returns a Connection to the database. Notice that it can never return null. If no connection can be acquired, then a SQLException is thrown.

Returns:
A connection to the database.
Throws:
SQLException - if there were problems trying to acquire the connection.

release

void release(Connection conn)
Release this connection. If this connection handler is using a database pool, the connection is returned to the pool. If this connection handler is not using a database pool, the connection is closed. If the connection passed as an argument is null, nothing is done.

Parameters:
conn - The connection to release.

destroy

void destroy()
Destroy the connection pool, closing and cleaning all connections. This is important for restarting the web context.

Since:
1.11

getStatus

String getStatus()
Print the status of this connection pool if any.

Returns:
The status

exec

void exec(ConnectionHandler.Exec exec)


Copyright © 2013. All Rights Reserved.