Class DefaultConnectionPoolFactory.DriverManagerDataSource
- java.lang.Object
-
- org.datanucleus.store.rdbms.connectionpool.DefaultConnectionPoolFactory.DriverManagerDataSource
-
- All Implemented Interfaces:
java.sql.Wrapper,javax.sql.CommonDataSource,javax.sql.DataSource
- Enclosing class:
- DefaultConnectionPoolFactory
public static class DefaultConnectionPoolFactory.DriverManagerDataSource extends java.lang.Object implements javax.sql.DataSourceWrapper 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
Fields Modifier and Type Field Description private org.datanucleus.ClassLoaderResolverclrClassLoader resolver to use for class loadingprivate java.lang.StringdriverNameName of the database driver.private java.lang.Stringpasswordthe passwordprivate java.util.Propertiespropsprivate java.lang.StringurlURL for the database.private java.lang.StringuserNamethe user name
-
Constructor Summary
Constructors Constructor Description DriverManagerDataSource(java.lang.String driverName, java.lang.String url, java.lang.String userName, java.lang.String password, org.datanucleus.ClassLoaderResolver clr, java.util.Properties props)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)Equality operator.java.sql.ConnectiongetConnection()Accessor for a JDBC connection for this data source.java.sql.ConnectiongetConnection(java.lang.String userName, java.lang.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.java.io.PrintWritergetLogWriter()Accessor for the LogWriter of the driver manager.java.util.logging.LoggergetParentLogger()inthashCode()Hashcode operator.booleanisWrapperFor(java.lang.Class iface)voidsetLoginTimeout(int seconds)Mutator for the Login timeout for the driver manager.voidsetLogWriter(java.io.PrintWriter out)Mutator for the LogWriter of the driver manager.java.lang.Objectunwrap(java.lang.Class iface)
-
-
-
Field Detail
-
driverName
private final java.lang.String driverName
Name of the database driver.
-
url
private final java.lang.String url
URL for the database.
-
clr
private final org.datanucleus.ClassLoaderResolver clr
ClassLoader resolver to use for class loading
-
userName
private final java.lang.String userName
the user name
-
password
private final java.lang.String password
the password
-
props
private final java.util.Properties props
-
-
Constructor Detail
-
DriverManagerDataSource
public DriverManagerDataSource(java.lang.String driverName, java.lang.String url, java.lang.String userName, java.lang.String password, org.datanucleus.ClassLoaderResolver clr, java.util.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 java.sql.Connection getConnection() throws java.sql.SQLExceptionAccessor for a JDBC connection for this data source.- Specified by:
getConnectionin interfacejavax.sql.DataSource- Returns:
- The connection
- Throws:
java.sql.SQLException- Thrown when an error occurs obtaining the connection.
-
getConnection
public java.sql.Connection getConnection(java.lang.String userName, java.lang.String password) throws java.sql.SQLExceptionAccessor for a JDBC connection for this data source, specifying username and password.- Specified by:
getConnectionin interfacejavax.sql.DataSource- 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:
java.sql.SQLException- Thrown when an error occurs obtaining the connection.
-
getLogWriter
public java.io.PrintWriter getLogWriter()
Accessor for the LogWriter of the driver manager.- Specified by:
getLogWriterin interfacejavax.sql.CommonDataSource- Specified by:
getLogWriterin interfacejavax.sql.DataSource- Returns:
- The Log Writer
-
setLogWriter
public void setLogWriter(java.io.PrintWriter out)
Mutator for the LogWriter of the driver manager.- Specified by:
setLogWriterin interfacejavax.sql.CommonDataSource- Specified by:
setLogWriterin interfacejavax.sql.DataSource- Parameters:
out- The Log Writer
-
getLoginTimeout
public int getLoginTimeout()
Accessor for the Login timeout for the driver manager.- Specified by:
getLoginTimeoutin interfacejavax.sql.CommonDataSource- Specified by:
getLoginTimeoutin interfacejavax.sql.DataSource- Returns:
- The login timeout (seconds)
-
setLoginTimeout
public void setLoginTimeout(int seconds)
Mutator for the Login timeout for the driver manager.- Specified by:
setLoginTimeoutin interfacejavax.sql.CommonDataSource- Specified by:
setLoginTimeoutin interfacejavax.sql.DataSource- Parameters:
seconds- The login timeout (seconds)
-
equals
public boolean equals(java.lang.Object obj)
Equality operator.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- The object to compare against.- Returns:
- Whether the objects are equal.
-
hashCode
public int hashCode()
Hashcode operator.- Overrides:
hashCodein classjava.lang.Object- Returns:
- The Hashcode for this object.
-
unwrap
public java.lang.Object unwrap(java.lang.Class iface) throws java.sql.SQLException- Specified by:
unwrapin interfacejava.sql.Wrapper- Throws:
java.sql.SQLException
-
isWrapperFor
public boolean isWrapperFor(java.lang.Class iface) throws java.sql.SQLException- Specified by:
isWrapperForin interfacejava.sql.Wrapper- Throws:
java.sql.SQLException
-
getParentLogger
public java.util.logging.Logger getParentLogger() throws java.sql.SQLFeatureNotSupportedException- Specified by:
getParentLoggerin interfacejavax.sql.CommonDataSource- Throws:
java.sql.SQLFeatureNotSupportedException
-
-