Top Description Fields Constructors Methods
org.springframework.jdbc.datasource

public abstract Class AbstractDataSource

extends Object
implements DataSource
Class Inheritance
All Implemented Interfaces
javax.sql.DataSource, java.sql.Wrapper, javax.sql.CommonDataSource
Known Direct Subclasses
org.springframework.jdbc.datasource.AbstractDriverBasedDataSource, org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource
Imports
java.io.PrintWriter, java.sql.SQLException, java.util.logging.Logger, javax.sql.DataSource, org.apache.commons.logging.Log, .LogFactory

Abstract base class for Spring's javax.sql.DataSource implementations, taking care of the padding.

'Padding' in the context of this class means default implementations for certain methods from the DataSource interface, such as getLoginTimeout(), setLoginTimeout(int), and so forth.

Author
Juergen Hoeller
Since
07.05.2003
See Also
DriverManagerDataSource

Field Summary

Modifier and TypeField and Description
protected final Log
logger

Logger available to subclasses.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
getLoginTimeout()

Implements javax.sql.DataSource.getLoginTimeout.

Returns 0, indicating the default system timeout is to be used.

public PrintWriter
getLogWriter()

Implements javax.sql.DataSource.getLogWriter.

LogWriter methods are not supported.

public Logger
getParentLogger()

Implements javax.sql.CommonDataSource.getParentLogger.

Return the parent Logger of all the Loggers used by this data source.

public boolean
isWrapperFor(Class<?>
a Class defining an interface.
iface
)

Implements java.sql.Wrapper.isWrapperFor.

Returns true if this either implements the interface argument or is directly or indirectly a wrapper for an object that does.

public void
setLoginTimeout(int
the data source login time limit
timeout
)

Implements javax.sql.DataSource.setLoginTimeout.

Setting a login timeout is not supported.

public void
setLogWriter(PrintWriter
the new log writer; to disable logging, set to null
pw
)

Implements javax.sql.DataSource.setLogWriter.

LogWriter methods are not supported.

public <T> T
unwrap(Class<T>
A Class defining an interface that the result must implement.
iface
)

Implements java.sql.Wrapper.unwrap.

Returns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

loggerback to summary
protected final Log logger

Logger available to subclasses.

Constructor Detail

AbstractDataSourceback to summary
public AbstractDataSource()

Method Detail

getLoginTimeoutback to summary
public int getLoginTimeout() throws SQLException

Implements javax.sql.DataSource.getLoginTimeout.

Returns 0, indicating the default system timeout is to be used.

Returns:int

Doc from javax.sql.CommonDataSource.getLoginTimeout.

the data source login time limit

Annotations
@Override
Exceptions
SQLException:

Doc from javax.sql.CommonDataSource.getLoginTimeout.

if a database access error occurs.

getLogWriterback to summary
public PrintWriter getLogWriter()

Implements javax.sql.DataSource.getLogWriter.

LogWriter methods are not supported.

Returns:PrintWriter

Doc from javax.sql.CommonDataSource.getLogWriter.

the log writer for this data source or null if logging is disabled

Annotations
@Override
getParentLoggerback to summary
public Logger getParentLogger()

Implements javax.sql.CommonDataSource.getParentLogger.

Doc from javax.sql.CommonDataSource.getParentLogger.

Return the parent Logger of all the Loggers used by this data source. This should be the Logger farthest from the root Logger that is still an ancestor of all of the Loggers used by this data source. Configuring this Logger will affect all of the log messages generated by the data source. In the worst case, this may be the root Logger.

Returns:Logger

the parent Logger for this data source

Annotations
@Override
isWrapperForback to summary
public boolean isWrapperFor(Class<?> iface) throws SQLException

Implements java.sql.Wrapper.isWrapperFor.

Doc from java.sql.Wrapper.isWrapperFor.

Returns true if this either implements the interface argument or is directly or indirectly a wrapper for an object that does. Returns false otherwise. If this implements the interface then return true, else if this is a wrapper then return the result of recursively calling isWrapperFor on the wrapped object. If this does not implement the interface and is not a wrapper, return false. This method should be implemented as a low-cost operation compared to unwrap so that callers can use this method to avoid expensive unwrap calls that may fail. If this method returns true then calling unwrap with the same argument should succeed.

Parameters
iface:Class<?>

a Class defining an interface.

Returns:boolean

true if this implements the interface or directly or indirectly wraps an object that does.

Annotations
@Override
Exceptions
SQLException:
if an error occurs while determining whether this is a wrapper for an object with the given interface.
setLoginTimeoutback to summary
public void setLoginTimeout(int timeout) throws SQLException

Implements javax.sql.DataSource.setLoginTimeout.

Setting a login timeout is not supported.

Parameters
timeout:int

Doc from javax.sql.CommonDataSource.setLoginTimeout.

the data source login time limit

Annotations
@Override
Exceptions
SQLException:

Doc from javax.sql.CommonDataSource.setLoginTimeout.

if a database access error occurs.

setLogWriterback to summary
public void setLogWriter(PrintWriter pw) throws SQLException

Implements javax.sql.DataSource.setLogWriter.

LogWriter methods are not supported.

Parameters
pw:PrintWriter

Doc from javax.sql.CommonDataSource.setLogWriter.

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

Annotations
@Override
Exceptions
SQLException:

Doc from javax.sql.CommonDataSource.setLogWriter.

if a database access error occurs

unwrapback to summary
public <T> T unwrap(Class<T> iface) throws SQLException

Implements java.sql.Wrapper.unwrap.

Doc from java.sql.Wrapper.unwrap.

Returns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy. If the receiver implements the interface then the result is the receiver or a proxy for the receiver. If the receiver is a wrapper and the wrapped object implements the interface then the result is the wrapped object or a proxy for the wrapped object. Otherwise return the the result of calling unwrap recursively on the wrapped object or a proxy for that result. If the receiver is not a wrapper and does not implement the interface, then an SQLException is thrown.

Parameters
<T>
the type of the class modeled by this Class object
iface:Class<T>

A Class defining an interface that the result must implement.

Returns:T

an object that implements the interface. May be a proxy for the actual implementing object.

Annotations
@Override
@SuppressWarnings:unchecked
Exceptions
SQLException:
If no object found that implements the interface