Class DefaultConnectionPoolFactory.DriverManagerDataSource
- java.lang.Object
-
- org.datanucleus.store.rdbms.connectionpool.DefaultConnectionPoolFactory.DriverManagerDataSource
-
- All Implemented Interfaces:
Wrapper,CommonDataSource,DataSource
- Enclosing class:
- DefaultConnectionPoolFactory
public static class DefaultConnectionPoolFactory.DriverManagerDataSource extends Object implements DataSource
Wrapper to the JDBC DataSource class. Provides checking for driver class existence, and utility methods for obtaining a connection.It should be noted that setting the log writer and login timeout will apply to DriverManager and NOT to the Data Source on its own. If you have 2 or more DataSource's they will have THE SAME log writer and login timeout.
-
-
Constructor Summary
Constructors Constructor Description DriverManagerDataSource(String driverName, String url, String userName, String password, org.datanucleus.ClassLoaderResolver clr, Properties props)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)Equality operator.ConnectiongetConnection()Accessor for a JDBC connection for this data source.ConnectiongetConnection(String userName, String password)Accessor for a JDBC connection for this data source, specifying username and password.intgetLoginTimeout()Accessor for the Login timeout for the driver manager.PrintWritergetLogWriter()Accessor for the LogWriter of the driver manager.LoggergetParentLogger()inthashCode()Hashcode operator.booleanisWrapperFor(Class iface)voidsetLoginTimeout(int seconds)Mutator for the Login timeout for the driver manager.voidsetLogWriter(PrintWriter out)Mutator for the LogWriter of the driver manager.Objectunwrap(Class iface)-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.sql.CommonDataSource
createShardingKeyBuilder
-
Methods inherited from interface javax.sql.DataSource
createConnectionBuilder
-
-
-
-
Constructor Detail
-
DriverManagerDataSource
public DriverManagerDataSource(String driverName, String url, String userName, String password, org.datanucleus.ClassLoaderResolver clr, Properties props)
Constructor.- Parameters:
driverName- Class name of the JDBC driver.url- URL of the data source.userName- User namepassword- User passwordclr- ClassLoaderResolver to use for loading issuesprops- Any custom properties for the driver
-
-
Method Detail
-
getConnection
public Connection getConnection() throws SQLException
Accessor for a JDBC connection for this data source.- Specified by:
getConnectionin interfaceDataSource- Returns:
- The connection
- Throws:
SQLException- Thrown when an error occurs obtaining the connection.
-
getConnection
public Connection getConnection(String userName, String password) throws SQLException
Accessor for a JDBC connection for this data source, specifying username and password.- Specified by:
getConnectionin interfaceDataSource- Parameters:
userName- User name for the data source (this user name is ignored)password- Password for the data source (this password is ignored)- Returns:
- The connection
- Throws:
SQLException- Thrown when an error occurs obtaining the connection.
-
getLogWriter
public PrintWriter getLogWriter()
Accessor for the LogWriter of the driver manager.- Specified by:
getLogWriterin interfaceCommonDataSource- Specified by:
getLogWriterin interfaceDataSource- Returns:
- The Log Writer
-
setLogWriter
public void setLogWriter(PrintWriter out)
Mutator for the LogWriter of the driver manager.- Specified by:
setLogWriterin interfaceCommonDataSource- Specified by:
setLogWriterin interfaceDataSource- Parameters:
out- The Log Writer
-
getLoginTimeout
public int getLoginTimeout()
Accessor for the Login timeout for the driver manager.- Specified by:
getLoginTimeoutin interfaceCommonDataSource- Specified by:
getLoginTimeoutin interfaceDataSource- Returns:
- The login timeout (seconds)
-
setLoginTimeout
public void setLoginTimeout(int seconds)
Mutator for the Login timeout for the driver manager.- Specified by:
setLoginTimeoutin interfaceCommonDataSource- Specified by:
setLoginTimeoutin interfaceDataSource- Parameters:
seconds- The login timeout (seconds)
-
equals
public boolean equals(Object obj)
Equality operator.
-
hashCode
public int hashCode()
Hashcode operator.
-
unwrap
public Object unwrap(Class iface) throws SQLException
- Specified by:
unwrapin interfaceWrapper- Throws:
SQLException
-
isWrapperFor
public boolean isWrapperFor(Class iface) throws SQLException
- Specified by:
isWrapperForin interfaceWrapper- Throws:
SQLException
-
getParentLogger
public Logger getParentLogger() throws SQLFeatureNotSupportedException
- Specified by:
getParentLoggerin interfaceCommonDataSource- Throws:
SQLFeatureNotSupportedException
-
-