Package org.apache.log.output.db
Class DefaultDataSource
- java.lang.Object
-
- org.apache.log.output.db.DefaultDataSource
-
- All Implemented Interfaces:
java.sql.Wrapper,javax.sql.CommonDataSource,javax.sql.DataSource
public class DefaultDataSource extends java.lang.Object implements javax.sql.DataSourceA basic datasource that doesn't do any pooling but just wraps around default mechanisms.- Author:
- Peter Donald
-
-
Field Summary
Fields Modifier and Type Field Description private intm_loginTimeoutprivate java.io.PrintWriterm_logWriterprivate java.lang.Stringm_passwordprivate java.lang.Stringm_urlprivate java.lang.Stringm_username
-
Constructor Summary
Constructors Constructor Description DefaultDataSource(java.lang.String url, java.lang.String username, java.lang.String password)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.sql.ConnectiongetConnection()Attempt to establish a database connection.java.sql.ConnectiongetConnection(java.lang.String username, java.lang.String password)Attempt to establish a database connection.intgetLoginTimeout()Gets the maximum time in seconds that this data source can wait while attempting to connect to a database.java.io.PrintWritergetLogWriter()Get the log writer for this data source.java.util.logging.LoggergetParentLogger()booleanisWrapperFor(java.lang.Class<?> iface)voidsetLoginTimeout(int loginTimeout)Sets the maximum time in seconds that this data source will wait while attempting to connect to a database.voidsetLogWriter(java.io.PrintWriter logWriter)<T> Tunwrap(java.lang.Class<T> iface)
-
-
-
Method Detail
-
getConnection
public java.sql.Connection getConnection() throws java.sql.SQLExceptionAttempt to establish a database connection.- Specified by:
getConnectionin interfacejavax.sql.DataSource- Returns:
- the Connection
- Throws:
java.sql.SQLException
-
getConnection
public java.sql.Connection getConnection(java.lang.String username, java.lang.String password) throws java.sql.SQLExceptionAttempt to establish a database connection.- Specified by:
getConnectionin interfacejavax.sql.DataSource- Returns:
- the Connection
- Throws:
java.sql.SQLException
-
getLoginTimeout
public int getLoginTimeout() throws java.sql.SQLExceptionGets the maximum time in seconds that this data source can wait while attempting to connect to a database.- Specified by:
getLoginTimeoutin interfacejavax.sql.CommonDataSource- Specified by:
getLoginTimeoutin interfacejavax.sql.DataSource- Returns:
- the login time
- Throws:
java.sql.SQLException
-
getLogWriter
public java.io.PrintWriter getLogWriter() throws java.sql.SQLExceptionGet the log writer for this data source.- Specified by:
getLogWriterin interfacejavax.sql.CommonDataSource- Specified by:
getLogWriterin interfacejavax.sql.DataSource- Returns:
- the LogWriter
- Throws:
java.sql.SQLException
-
setLoginTimeout
public void setLoginTimeout(int loginTimeout) throws java.sql.SQLExceptionSets the maximum time in seconds that this data source will wait while attempting to connect to a database.- Specified by:
setLoginTimeoutin interfacejavax.sql.CommonDataSource- Specified by:
setLoginTimeoutin interfacejavax.sql.DataSource- Parameters:
loginTimeout- the loging timeout in seconds- Throws:
java.sql.SQLException
-
setLogWriter
public void setLogWriter(java.io.PrintWriter logWriter) throws java.sql.SQLException- Specified by:
setLogWriterin interfacejavax.sql.CommonDataSource- Specified by:
setLogWriterin interfacejavax.sql.DataSource- Throws:
java.sql.SQLException
-
isWrapperFor
public boolean isWrapperFor(java.lang.Class<?> iface)
- Specified by:
isWrapperForin interfacejava.sql.Wrapper
-
unwrap
public <T> T unwrap(java.lang.Class<T> iface)
- Specified by:
unwrapin interfacejava.sql.Wrapper
-
getParentLogger
public java.util.logging.Logger getParentLogger()
- Specified by:
getParentLoggerin interfacejavax.sql.CommonDataSource
-
-