org.apache.log.output.db
Class DefaultDataSource

java.lang.Object
  extended by org.apache.log.output.db.DefaultDataSource
All Implemented Interfaces:
Wrapper, CommonDataSource, DataSource

public class DefaultDataSource
extends Object
implements DataSource

A basic datasource that doesn't do any pooling but just wraps around default mechanisms.

Author:
Peter Donald

Field Summary
private  int m_loginTimeout
           
private  PrintWriter m_logWriter
           
private  String m_password
           
private  String m_url
           
private  String m_username
           
 
Constructor Summary
DefaultDataSource(String url, String username, String password)
           
 
Method Summary
 Connection getConnection()
          Attempt to establish a database connection.
 Connection getConnection(String username, String password)
          Attempt to establish a database connection.
 int getLoginTimeout()
          Gets the maximum time in seconds that this data source can wait while attempting to connect to a database.
 PrintWriter getLogWriter()
          Get the log writer for this data source.
 boolean isWrapperFor(Class iface)
           
 void setLoginTimeout(int loginTimeout)
          Sets the maximum time in seconds that this data source will wait while attempting to connect to a database.
 void setLogWriter(PrintWriter logWriter)
           
 Object unwrap(Class iface)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_username

private final String m_username

m_password

private final String m_password

m_url

private final String m_url

m_logWriter

private PrintWriter m_logWriter

m_loginTimeout

private int m_loginTimeout
Constructor Detail

DefaultDataSource

public DefaultDataSource(String url,
                         String username,
                         String password)
Method Detail

getConnection

public Connection getConnection()
                         throws SQLException
Attempt to establish a database connection.

Specified by:
getConnection in interface DataSource
Returns:
the Connection
Throws:
SQLException

getConnection

public Connection getConnection(String username,
                                String password)
                         throws SQLException
Attempt to establish a database connection.

Specified by:
getConnection in interface DataSource
Returns:
the Connection
Throws:
SQLException

getLoginTimeout

public int getLoginTimeout()
                    throws SQLException
Gets the maximum time in seconds that this data source can wait while attempting to connect to a database.

Specified by:
getLoginTimeout in interface CommonDataSource
Returns:
the login time
Throws:
SQLException

getLogWriter

public PrintWriter getLogWriter()
                         throws SQLException
Get the log writer for this data source.

Specified by:
getLogWriter in interface CommonDataSource
Returns:
the LogWriter
Throws:
SQLException

setLoginTimeout

public void setLoginTimeout(int loginTimeout)
                     throws SQLException
Sets the maximum time in seconds that this data source will wait while attempting to connect to a database.

Specified by:
setLoginTimeout in interface CommonDataSource
Parameters:
loginTimeout - the loging timeout in seconds
Throws:
SQLException

setLogWriter

public void setLogWriter(PrintWriter logWriter)
                  throws SQLException
Specified by:
setLogWriter in interface CommonDataSource
Throws:
SQLException

unwrap

public Object unwrap(Class iface)
              throws SQLException
Specified by:
unwrap in interface Wrapper
Throws:
SQLException

isWrapperFor

public boolean isWrapperFor(Class iface)
                     throws SQLException
Specified by:
isWrapperFor in interface Wrapper
Throws:
SQLException


Copyright © 2003-2004 The Apache Software Foundation. All Rights Reserved.