Top Description Fields Constructors Methods
org.apache.log.output.db

public Class DefaultDataSource

extends Object
implements DataSource
Class Inheritance
All Implemented Interfaces
javax.sql.DataSource, java.sql.Wrapper, javax.sql.CommonDataSource
Imports
java.io.PrintWriter, java.sql.Connection, .DriverManager, .SQLException, javax.sql.DataSource

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

Field Summary

Modifier and TypeField and Description
private int
private PrintWriter
private final String
private final String
private final String

Constructor Summary

AccessConstructor and Description
public
DefaultDataSource(final String url, final String username, final String password)

Method Summary

Modifier and TypeMethod and Description
public Connection

Returns:

the Connection
getConnection
()

Implements javax.sql.DataSource.getConnection.

Attempt to establish a database connection.
public Connection

Returns:

the Connection
getConnection
(final String
the database user on whose behalf the connection is being made
username
,
final String
the user's password
password
)

Implements javax.sql.DataSource.getConnection.

Attempt to establish a database connection.
public int

Returns:

the login time
getLoginTimeout
()

Implements javax.sql.DataSource.getLoginTimeout.

Gets the maximum time in seconds that this data source can wait while attempting to connect to a database.
public PrintWriter

Returns:

the LogWriter
getLogWriter
()

Implements javax.sql.DataSource.getLogWriter.

Get the log writer for this data source.
public void
setLoginTimeout(final int
the loging timeout in seconds
loginTimeout
)

Implements javax.sql.DataSource.setLoginTimeout.

Sets the maximum time in seconds that this data source will wait while attempting to connect to a database.
public void
setLogWriter(final PrintWriter
the new log writer; to disable logging, set to null
logWriter
)

Implements javax.sql.DataSource.setLogWriter.

Sets the log writer for this DataSource object to the given java.io.PrintWriter object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

m_loginTimeoutback to summary
private int m_loginTimeout
m_logWriterback to summary
private PrintWriter m_logWriter
m_passwordback to summary
private final String m_password
m_urlback to summary
private final String m_url
m_usernameback to summary
private final String m_username

Constructor Detail

DefaultDataSourceback to summary
public DefaultDataSource(final String url, final String username, final String password)

Method Detail

getConnectionback to summary
public Connection getConnection() throws SQLException

Implements javax.sql.DataSource.getConnection.

Attempt to establish a database connection.

Returns:Connection

the Connection

Exceptions
SQLException:

Doc from javax.sql.DataSource.getConnection.

if a database access error occurs

getConnectionback to summary
public Connection getConnection(final String username, final String password) throws SQLException

Implements javax.sql.DataSource.getConnection.

Attempt to establish a database connection.

Parameters
username:String

Doc from javax.sql.DataSource.getConnection.

the database user on whose behalf the connection is being made

password:String

Doc from javax.sql.DataSource.getConnection.

the user's password

Returns:Connection

the Connection

Exceptions
SQLException:

Doc from javax.sql.DataSource.getConnection.

if a database access error occurs

getLoginTimeoutback to summary
public int getLoginTimeout() throws SQLException

Implements javax.sql.DataSource.getLoginTimeout.

Gets the maximum time in seconds that this data source can wait while attempting to connect to a database.

Returns:int

the login time

Exceptions
SQLException:

Doc from javax.sql.CommonDataSource.getLoginTimeout.

if a database access error occurs.

getLogWriterback to summary
public PrintWriter getLogWriter() throws SQLException

Implements javax.sql.DataSource.getLogWriter.

Get the log writer for this data source.

Returns:PrintWriter

the LogWriter

Exceptions
SQLException:

Doc from javax.sql.CommonDataSource.getLogWriter.

if a database access error occurs

setLoginTimeoutback to summary
public void setLoginTimeout(final int loginTimeout) throws SQLException

Implements javax.sql.DataSource.setLoginTimeout.

Sets the maximum time in seconds that this data source will wait while attempting to connect to a database.

Parameters
loginTimeout:int

the loging timeout in seconds

Exceptions
SQLException:

Doc from javax.sql.CommonDataSource.setLoginTimeout.

if a database access error occurs.

setLogWriterback to summary
public void setLogWriter(final PrintWriter logWriter) throws SQLException

Implements javax.sql.DataSource.setLogWriter.

Doc from javax.sql.DataSource.setLogWriter.

Sets the log writer for this DataSource object to the given java.io.PrintWriter object.

The log writer is a character output stream to which all logging and tracing messages for this data source will be printed. This includes messages printed by the methods of this object, messages printed by methods of other objects manufactured by this object, and so on. Messages printed to a data source- specific log writer are not printed to the log writer associated with the java.sql.DriverManager class. When a DataSource object is created the log writer is initially null; in other words, the default is for logging to be disabled.

Parameters
logWriter:PrintWriter

Doc from javax.sql.CommonDataSource.setLogWriter.

the new log writer; to disable logging, set to null

Exceptions
SQLException:

Doc from javax.sql.CommonDataSource.setLogWriter.

if a database access error occurs