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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.datanucleus.ClassLoaderResolver
ClassLoader resolver to use for class loadingprivate final String
Name of the database driver.private final String
the passwordprivate final Properties
private final String
URL for the database.private final String
the user name -
Constructor Summary
ConstructorsConstructorDescriptionDriverManagerDataSource
(String driverName, String url, String userName, String password, org.datanucleus.ClassLoaderResolver clr, Properties props) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Equality operator.Accessor for a JDBC connection for this data source.getConnection
(String userName, String password) Accessor for a JDBC connection for this data source, specifying username and password.int
Accessor for the Login timeout for the driver manager.Accessor for the LogWriter of the driver manager.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.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
-
Field Details
-
driverName
Name of the database driver. -
url
URL for the database. -
clr
private final org.datanucleus.ClassLoaderResolver clrClassLoader resolver to use for class loading -
userName
the user name -
password
the password -
props
-
-
Constructor Details
-
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 Details
-
getConnection
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
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
Accessor for the LogWriter of the driver manager.- Specified by:
getLogWriter
in interfaceCommonDataSource
- Specified by:
getLogWriter
in interfaceDataSource
- Returns:
- The Log Writer
-
setLogWriter
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
Equality operator. -
hashCode
public int hashCode()Hashcode operator. -
unwrap
- Specified by:
unwrap
in interfaceWrapper
- Throws:
SQLException
-
isWrapperFor
- Specified by:
isWrapperFor
in interfaceWrapper
- Throws:
SQLException
-
getParentLogger
- Specified by:
getParentLogger
in interfaceCommonDataSource
- Throws:
SQLFeatureNotSupportedException
-