Top Fields Constructors Methods
com.mchange.v2.c3p0

public final Class DriverManagerDataSource

extends DriverManagerDataSourceBase
implements DataSource
Class Inheritance
All Implemented Interfaces
javax.sql.DataSource, java.sql.Wrapper, javax.sql.CommonDataSource
Imports
java.beans.PropertyChangeEvent, .PropertyChangeListener, java.io.IOException, .ObjectInputStream, .ObjectOutputStream, .PrintWriter, java.util.Properties, java.sql.Connection, .Driver, .DriverManager, .SQLException, javax.sql.DataSource, com.mchange.v2.sql.SqlUtils, com.mchange.v2.log.MLevel, .MLog, .MLogger, com.mchange.v2.c3p0.cfg.C3P0Config, com.mchange.v2.c3p0.impl.DriverManagerDataSourceBase

Field Summary

Modifier and TypeField and Description
pack-priv Driver
pack-priv boolean
pack-priv static final MLogger
private static final long
private static final short
Inherited from com.mchange.v2.c3p0.impl.DriverManagerDataSourceBase:
descriptiondriverClassfactoryClassLocationforceUseNamedDriverClassjdbcUrlpcsproperties

Constructor Summary

AccessConstructor and Description
public
public
DriverManagerDataSource(boolean autoregister)

Method Summary

Modifier and TypeMethod and Description
private synchronized void
private synchronized Driver
private synchronized void
private static boolean
public Connection
getConnection()

Implements javax.sql.DataSource.getConnection.

Attempts to establish a connection with the data source that this DataSource object represents.

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

Implements javax.sql.DataSource.getConnection.

Attempts to establish a connection with the data source that this DataSource object represents.

public int
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
getLogWriter()

Implements javax.sql.DataSource.getLogWriter.

Retrieves the log writer for this DataSource object.

public synchronized String
public synchronized String
private synchronized boolean
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.

private boolean
private Class<T>
loadDriverClass(String driverClass)

private void
private final Properties
overrideProps(String user, String password)

private void
private synchronized void
setDriverClassLoaded(boolean dcl)

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

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(PrintWriter
the new log writer; to disable logging, set to null
out
)

Implements javax.sql.DataSource.setLogWriter.

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

public synchronized void
setPassword(String password)

private void
public synchronized void
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.

private void
Inherited from com.mchange.v2.c3p0.impl.DriverManagerDataSourceBase:
addPropertyChangeListeneraddPropertyChangeListenerextraToStringInfogetDescriptiongetDriverClassgetFactoryClassLocationgetIdentityTokengetJdbcUrlgetParentLoggergetPropertiesgetPropertyChangeListenersgetPropertyChangeSupportgetReferenceisForceUseNamedDriverClassremovePropertyChangeListenerremovePropertyChangeListenersetDescriptionsetDriverClasssetFactoryClassLocationsetForceUseNamedDriverClasssetIdentityTokensetPropertiestoString

Field Detail

driverback to summary
pack-priv Driver driver
driver_class_loadedback to summary
pack-priv boolean driver_class_loaded
loggerback to summary
pack-priv static final MLogger logger
serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.mchange.v2.c3p0.impl.DriverManagerDataSourceBase.serialVersionUID.

VERSIONback to summary
private static final short VERSION

Hides com.mchange.v2.c3p0.impl.DriverManagerDataSourceBase.VERSION.

Constructor Detail

DriverManagerDataSourceback to summary
public DriverManagerDataSource()
DriverManagerDataSourceback to summary
public DriverManagerDataSource(boolean autoregister)

Method Detail

clearDriverback to summary
private synchronized void clearDriver()
driverback to summary
private synchronized Driver driver() throws SQLException
ensureIfPossibleDriverClassLoadedback to summary
private synchronized void ensureIfPossibleDriverClassLoaded() throws SQLException
eqOrBothNullback to summary
private static boolean eqOrBothNull(Object a, Object b)

Hides com.mchange.v2.c3p0.impl.DriverManagerDataSourceBase.eqOrBothNull.

getConnectionback to summary
public Connection getConnection() throws SQLException

Implements javax.sql.DataSource.getConnection.

Doc from javax.sql.DataSource.getConnection.

Attempts to establish a connection with the data source that this DataSource object represents.

Returns:Connection

a connection to the data source

Exceptions
SQLException:
if a database access error occurs
getConnectionback to summary
public Connection getConnection(String username, String password) throws SQLException

Implements javax.sql.DataSource.getConnection.

Doc from javax.sql.DataSource.getConnection.

Attempts to establish a connection with the data source that this DataSource object represents.

Parameters
username:String

the database user on whose behalf the connection is being made

password:String

the user's password

Returns:Connection

a connection to the data source

Exceptions
SQLException:
if a database access error occurs
getLoginTimeoutback to summary
public int getLoginTimeout() throws SQLException

Implements javax.sql.DataSource.getLoginTimeout.

Doc from javax.sql.DataSource.getLoginTimeout.

Gets the maximum time in seconds that this data source can wait while attempting to connect to a database. A value of zero means that the timeout is the default system timeout if there is one; otherwise, it means that there is no timeout. When a DataSource object is created, the login timeout is initially zero.

Returns:int

Doc from javax.sql.CommonDataSource.getLoginTimeout.

the data source login time limit

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.

Doc from javax.sql.DataSource.getLogWriter.

Retrieves the log writer for this DataSource 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.

Returns:PrintWriter

Doc from javax.sql.CommonDataSource.getLogWriter.

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

Exceptions
SQLException:

Doc from javax.sql.CommonDataSource.getLogWriter.

if a database access error occurs

getPasswordback to summary
public synchronized String getPassword()
getUserback to summary
public synchronized String getUser()
isDriverClassLoadedback to summary
private synchronized boolean isDriverClassLoaded()
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.

Exceptions
SQLException:
if an error occurs while determining whether this is a wrapper for an object with the given interface.
isWrapperForThisback to summary
private boolean isWrapperForThis(Class<?> iface)
loadDriverClassback to summary
private Class<T> loadDriverClass(String driverClass) throws ClassNotFoundException
logCircumventingDriverManagerback to summary
private void logCircumventingDriverManager()
overridePropsback to summary
private final Properties overrideProps(String user, String password)
readObjectback to summary
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException

Hides com.mchange.v2.c3p0.impl.DriverManagerDataSourceBase.readObject.

setDriverClassLoadedback to summary
private synchronized void setDriverClassLoaded(boolean dcl)
setJdbcUrlback to summary
public synchronized void setJdbcUrl(String jdbcUrl)

Overrides com.mchange.v2.c3p0.impl.DriverManagerDataSourceBase.setJdbcUrl.

setLoginTimeoutback to summary
public void setLoginTimeout(int seconds) throws SQLException

Implements javax.sql.DataSource.setLoginTimeout.

Doc from javax.sql.DataSource.setLoginTimeout.

Sets the maximum time in seconds that this data source will wait while attempting to connect to a database. A value of zero specifies that the timeout is the default system timeout if there is one; otherwise, it specifies that there is no timeout. When a DataSource object is created, the login timeout is initially zero.

Parameters
seconds:int

Doc from javax.sql.CommonDataSource.setLoginTimeout.

the data source login time limit

Exceptions
SQLException:

Doc from javax.sql.CommonDataSource.setLoginTimeout.

if a database access error occurs.

setLogWriterback to summary
public void setLogWriter(PrintWriter out) 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
out: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

setPasswordback to summary
public synchronized void setPassword(String password)
setUpPropertyListenersback to summary
private void setUpPropertyListeners()
setUserback to summary
public synchronized void setUser(String user)
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.

Exceptions
SQLException:
If no object found that implements the interface
writeObjectback to summary
private void writeObject(ObjectOutputStream oos) throws IOException

Hides com.mchange.v2.c3p0.impl.DriverManagerDataSourceBase.writeObject.