public class DataManagerDataSource
extends java.lang.Object
implements javax.sql.DataSource
Modifier and Type | Class and Description |
---|---|
class |
DataManagerDataSource.ManagedConnection
Wrapper for connections
|
static class |
DataManagerDataSource.QueryLogger
A class used for logging query events (debugging purposes)
|
Constructor and Description |
---|
DataManagerDataSource(javax.sql.DataSource dataSource,
ScrapingSession session,
SqlDataManager.SqlDataManagerLogger logger)
Creates a data manager data source
|
DataManagerDataSource(javax.sql.DataSource dataSource,
ScrapingSession session,
SqlDataManager.SqlDataManagerLogger logger,
DataManagerDataSource.QueryLogger queryLogger)
Creates a data manager data source
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the underlying DataSource (if it has a close method).
|
java.sql.Connection |
getConnection() |
java.sql.Connection |
getConnection(java.lang.String connectionName)
Gets a connection and gives it a name for debugging purposes
|
java.sql.Connection |
getConnection(java.lang.String username,
java.lang.String password) |
java.sql.Connection |
getConnection(java.lang.String connectionName,
java.lang.String username,
java.lang.String password)
Gets a connection and gives it a name for debugging purposes
|
SqlDataManager.SqlDataManagerLogger |
getLogger()
Returns the logger in use by the data source
|
int |
getLoginTimeout() |
java.io.PrintWriter |
getLogWriter() |
java.util.logging.Logger |
getParentLogger() |
DataManagerDataSource.QueryLogger |
getQueryLogger()
Returns the QueryLogger for the object
|
boolean |
isWrapperFor(java.lang.Class<?> iface) |
void |
setLoginTimeout(int seconds) |
void |
setLogWriter(java.io.PrintWriter out) |
void |
setQueryLogger(DataManagerDataSource.QueryLogger queryLogger)
Sets the QueryLogger for the object, which is used for gathering information about all queries run on the data source
|
void |
startConnectionMonitorThread()
Starts the thread that logs out information about old connections
|
java.lang.String |
toString() |
<T> T |
unwrap(java.lang.Class<T> iface) |
public DataManagerDataSource(@NotNull javax.sql.DataSource dataSource, @Nullable ScrapingSession session, @NotNull SqlDataManager.SqlDataManagerLogger logger)
dataSource
- The source to wrapsession
- The sessionlogger
- The logger for writing to the session (or elsewhere if desired)public DataManagerDataSource(@NotNull javax.sql.DataSource dataSource, @Nullable ScrapingSession session, @NotNull SqlDataManager.SqlDataManagerLogger logger, @NotNull DataManagerDataSource.QueryLogger queryLogger)
dataSource
- The source to wrapsession
- The sessionlogger
- The logger for writing to the session (or elsewhere if desired)queryLogger
- A QueryLogger object used for debugging. It is called at various times to allow logging queries run through the source@InternalOnly public SqlDataManager.SqlDataManagerLogger getLogger()
@NotNull @InternalOnly public DataManagerDataSource.QueryLogger getQueryLogger()
public void setQueryLogger(@NotNull DataManagerDataSource.QueryLogger queryLogger)
queryLogger
- The new value for QueryLoggerpublic void startConnectionMonitorThread()
public void close()
public java.sql.Connection getConnection() throws java.sql.SQLException
getConnection
in interface javax.sql.DataSource
java.sql.SQLException
public java.sql.Connection getConnection(java.lang.String connectionName) throws java.sql.SQLException
connectionName
- The name for the connectionjava.sql.SQLException
- On error connecting to the databasepublic java.sql.Connection getConnection(java.lang.String username, java.lang.String password) throws java.sql.SQLException
getConnection
in interface javax.sql.DataSource
java.sql.SQLException
public java.sql.Connection getConnection(java.lang.String connectionName, java.lang.String username, java.lang.String password) throws java.sql.SQLException
connectionName
- The name for the connectionusername
- The username for this connectionpassword
- The password for this connectionjava.sql.SQLException
- On error connecting to the databasepublic java.io.PrintWriter getLogWriter() throws java.sql.SQLException
getLogWriter
in interface javax.sql.CommonDataSource
java.sql.SQLException
public void setLogWriter(java.io.PrintWriter out) throws java.sql.SQLException
setLogWriter
in interface javax.sql.CommonDataSource
java.sql.SQLException
public void setLoginTimeout(int seconds) throws java.sql.SQLException
setLoginTimeout
in interface javax.sql.CommonDataSource
java.sql.SQLException
public int getLoginTimeout() throws java.sql.SQLException
getLoginTimeout
in interface javax.sql.CommonDataSource
java.sql.SQLException
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException
unwrap
in interface java.sql.Wrapper
java.sql.SQLException
public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException
isWrapperFor
in interface java.sql.Wrapper
java.sql.SQLException
@NotNull public java.util.logging.Logger getParentLogger() throws java.sql.SQLFeatureNotSupportedException
getParentLogger
in interface javax.sql.CommonDataSource
java.sql.SQLFeatureNotSupportedException
@NotNull public java.lang.String toString()
toString
in class java.lang.Object