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.ClassLoaderResolverClassLoader resolver to use for class loadingprivate final StringName of the database driver.private final Stringthe passwordprivate final Propertiesprivate final StringURL for the database.private final Stringthe user name -
Constructor Summary
ConstructorsConstructorDescriptionDriverManagerDataSource(String driverName, String url, String userName, String password, org.datanucleus.ClassLoaderResolver clr, Properties props) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanEquality 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.intAccessor for the Login timeout for the driver manager.Accessor for the LogWriter of the driver manager.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.Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface CommonDataSource
createShardingKeyBuilderMethods inherited from interface 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:
getConnectionin 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:
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
Accessor for the LogWriter of the driver manager.- Specified by:
getLogWriterin interfaceCommonDataSource- Specified by:
getLogWriterin interfaceDataSource- Returns:
- The Log Writer
-
setLogWriter
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
-
hashCode
-
unwrap
- Specified by:
unwrapin interfaceWrapper- Throws:
SQLException
-
isWrapperFor
- Specified by:
isWrapperForin interfaceWrapper- Throws:
SQLException
-
getParentLogger
- Specified by:
getParentLoggerin interfaceCommonDataSource- Throws:
SQLFeatureNotSupportedException
-