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.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
Fields Modifier and Type Field Description private org.datanucleus.ClassLoaderResolver
clr
ClassLoader resolver to use for class loadingprivate java.lang.String
driverName
Name of the database driver.private java.lang.String
password
the passwordprivate java.util.Properties
props
private java.lang.String
url
URL for the database.private java.lang.String
userName
the 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 boolean
equals(java.lang.Object obj)
Equality operator.java.sql.Connection
getConnection()
Accessor for a JDBC connection for this data source.java.sql.Connection
getConnection(java.lang.String userName, java.lang.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.java.io.PrintWriter
getLogWriter()
Accessor for the LogWriter of the driver manager.java.util.logging.Logger
getParentLogger()
int
hashCode()
Hashcode operator.boolean
isWrapperFor(java.lang.Class iface)
void
setLoginTimeout(int seconds)
Mutator for the Login timeout for the driver manager.void
setLogWriter(java.io.PrintWriter out)
Mutator for the LogWriter of the driver manager.java.lang.Object
unwrap(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.SQLException
Accessor for a JDBC connection for this data source.- Specified by:
getConnection
in 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.SQLException
Accessor for a JDBC connection for this data source, specifying username and password.- Specified by:
getConnection
in 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:
getLogWriter
in interfacejavax.sql.CommonDataSource
- Specified by:
getLogWriter
in 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:
setLogWriter
in interfacejavax.sql.CommonDataSource
- Specified by:
setLogWriter
in interfacejavax.sql.DataSource
- Parameters:
out
- The Log Writer
-
getLoginTimeout
public int getLoginTimeout()
Accessor for the Login timeout for the driver manager.- Specified by:
getLoginTimeout
in interfacejavax.sql.CommonDataSource
- Specified by:
getLoginTimeout
in 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:
setLoginTimeout
in interfacejavax.sql.CommonDataSource
- Specified by:
setLoginTimeout
in interfacejavax.sql.DataSource
- Parameters:
seconds
- The login timeout (seconds)
-
equals
public boolean equals(java.lang.Object obj)
Equality operator.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- The object to compare against.- Returns:
- Whether the objects are equal.
-
hashCode
public int hashCode()
Hashcode operator.- Overrides:
hashCode
in 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:
unwrap
in interfacejava.sql.Wrapper
- Throws:
java.sql.SQLException
-
isWrapperFor
public boolean isWrapperFor(java.lang.Class iface) throws java.sql.SQLException
- Specified by:
isWrapperFor
in interfacejava.sql.Wrapper
- Throws:
java.sql.SQLException
-
getParentLogger
public java.util.logging.Logger getParentLogger() throws java.sql.SQLFeatureNotSupportedException
- Specified by:
getParentLogger
in interfacejavax.sql.CommonDataSource
- Throws:
java.sql.SQLFeatureNotSupportedException
-
-