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 boolean
equals(Object obj)
Equality operator.Connection
getConnection()
Accessor for a JDBC connection for this data source.Connection
getConnection(String userName, String password)
Accessor for a JDBC connection for this data source, specifying username and password.int
getLoginTimeout()
Accessor for the Login timeout for the driver manager.PrintWriter
getLogWriter()
Accessor for the LogWriter of the driver manager.Logger
getParentLogger()
int
hashCode()
Hashcode operator.boolean
isWrapperFor(Class iface)
void
setLoginTimeout(int seconds)
Mutator for the Login timeout for the driver manager.void
setLogWriter(PrintWriter out)
Mutator for the LogWriter of the driver manager.Object
unwrap(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:
getConnection
in 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:
getConnection
in 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:
getLogWriter
in interfaceCommonDataSource
- Specified by:
getLogWriter
in interfaceDataSource
- Returns:
- The Log Writer
-
setLogWriter
public void setLogWriter(PrintWriter out)
Mutator for the LogWriter of the driver manager.- Specified by:
setLogWriter
in interfaceCommonDataSource
- Specified by:
setLogWriter
in interfaceDataSource
- Parameters:
out
- The Log Writer
-
getLoginTimeout
public int getLoginTimeout()
Accessor for the Login timeout for the driver manager.- Specified by:
getLoginTimeout
in interfaceCommonDataSource
- Specified by:
getLoginTimeout
in interfaceDataSource
- Returns:
- The login timeout (seconds)
-
setLoginTimeout
public void setLoginTimeout(int seconds)
Mutator for the Login timeout for the driver manager.- Specified by:
setLoginTimeout
in interfaceCommonDataSource
- Specified by:
setLoginTimeout
in 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:
unwrap
in interfaceWrapper
- Throws:
SQLException
-
isWrapperFor
public boolean isWrapperFor(Class iface) throws SQLException
- Specified by:
isWrapperFor
in interfaceWrapper
- Throws:
SQLException
-
getParentLogger
public Logger getParentLogger() throws SQLFeatureNotSupportedException
- Specified by:
getParentLogger
in interfaceCommonDataSource
- Throws:
SQLFeatureNotSupportedException
-
-