org.nanocontainer.persistence.jdbc
Class AbstractDataSource

java.lang.Object
  extended by org.nanocontainer.persistence.jdbc.AbstractDataSource
All Implemented Interfaces:
DataSource
Direct Known Subclasses:
DBCPDataSource, JNDIDataSource

public abstract class AbstractDataSource
extends Object
implements DataSource

Base classe for DataSource components. It delegates all calls to the datasource obtained by getDelegatedDataSource method. Error handling is also there.

Version:
$Id: AbstractDataSource.java 2653 2005-10-16 12:50:07Z juze $
Author:
Juze Peleteiro

Constructor Summary
protected AbstractDataSource()
           
protected AbstractDataSource(ExceptionHandler jdbcExceptionHandler)
           
 
Method Summary
 Connection getConnection()
           
 Connection getConnection(String username, String password)
           
protected abstract  DataSource getDelegatedDataSource()
           
 int getLoginTimeout()
           
 PrintWriter getLogWriter()
           
protected  SQLException handleException(Exception cause)
          Invalidates the connection calling #invalidateDelegatedConnection() and convert the cause using a ExceptionHandler.
protected abstract  void invalidateDelegatedDataSource()
           
 void setLoginTimeout(int seconds)
           
 void setLogWriter(PrintWriter out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDataSource

protected AbstractDataSource(ExceptionHandler jdbcExceptionHandler)

AbstractDataSource

protected AbstractDataSource()
Method Detail

getDelegatedDataSource

protected abstract DataSource getDelegatedDataSource()
                                              throws Exception
Throws:
Exception

invalidateDelegatedDataSource

protected abstract void invalidateDelegatedDataSource()
                                               throws Exception
Throws:
Exception

handleException

protected SQLException handleException(Exception cause)
                                throws RuntimeException
Invalidates the connection calling #invalidateDelegatedConnection() and convert the cause using a ExceptionHandler. if it's available otherwise just return the cause back.

Throws:
RuntimeException

getConnection

public Connection getConnection()
                         throws SQLException
Specified by:
getConnection in interface DataSource
Throws:
SQLException
See Also:
DataSource.getConnection()

getConnection

public Connection getConnection(String username,
                                String password)
                         throws SQLException
Specified by:
getConnection in interface DataSource
Throws:
SQLException
See Also:
DataSource.getConnection(java.lang.String, java.lang.String)

getLogWriter

public PrintWriter getLogWriter()
                         throws SQLException
Specified by:
getLogWriter in interface DataSource
Throws:
SQLException
See Also:
DataSource.getLogWriter()

setLogWriter

public void setLogWriter(PrintWriter out)
                  throws SQLException
Specified by:
setLogWriter in interface DataSource
Throws:
SQLException
See Also:
DataSource.setLogWriter(java.io.PrintWriter)

setLoginTimeout

public void setLoginTimeout(int seconds)
                     throws SQLException
Specified by:
setLoginTimeout in interface DataSource
Throws:
SQLException
See Also:
DataSource.setLoginTimeout(int)

getLoginTimeout

public int getLoginTimeout()
                    throws SQLException
Specified by:
getLoginTimeout in interface DataSource
Throws:
SQLException
See Also:
DataSource.getLoginTimeout()


Copyright 2003-2003-2006 Codehaus. All Rights Reserved.