public class IndependentDataSource
extends java.lang.Object
implements javax.sql.DataSource
| Constructor and Description |
|---|
IndependentDataSource(PluginService pluginService)
Creates an IndependentDataSource with the given PluginService.
|
IndependentDataSource(PluginService pluginService,
java.util.Properties connectionProperties)
Creates an IndependentDataSource with PluginService and connection properties.
|
| Modifier and Type | Method and Description |
|---|---|
java.sql.Connection |
getConnection() |
java.sql.Connection |
getConnection(java.lang.String username,
java.lang.String password) |
long |
getConnectionRequestCount()
Gets the total number of connection requests made to this DataSource.
|
double |
getConnectionSuccessRate()
Calculates the connection success rate as a percentage.
|
long |
getFailedConnectionCount()
Gets the number of failed connection creation attempts.
|
java.lang.String |
getHealthStatus()
Gets a comprehensive status message about the DataSource health and metrics.
|
long |
getLastFailedConnectionTime()
Gets the timestamp of the last failed connection attempt.
|
long |
getLastSuccessfulConnectionTime()
Gets the timestamp of the last successful connection creation.
|
int |
getLoginTimeout() |
java.io.PrintWriter |
getLogWriter() |
java.util.logging.Logger |
getParentLogger() |
PluginService |
getPluginService()
Gets the PluginService used by this DataSource.
|
long |
getSuccessfulConnectionCount()
Gets the number of successful connection creations.
|
boolean |
isHealthy()
Checks if the DataSource is currently healthy based on recent connection attempts.
|
boolean |
isWrapperFor(java.lang.Class<?> iface) |
void |
logHealthStatus()
Logs the current health status and metrics.
|
void |
setLoginTimeout(int seconds) |
void |
setLogWriter(java.io.PrintWriter out) |
<T> T |
unwrap(java.lang.Class<T> iface) |
boolean |
validateConnection()
Validates that a connection can be created with the current PluginService.
|
public IndependentDataSource(PluginService pluginService)
pluginService - the PluginService to use for creating connectionsjava.lang.IllegalArgumentException - if pluginService is nullpublic IndependentDataSource(PluginService pluginService, java.util.Properties connectionProperties)
pluginService - the PluginService to use for creating connectionsconnectionProperties - additional connection propertiesjava.lang.IllegalArgumentException - if pluginService is nullpublic java.sql.Connection getConnection()
throws java.sql.SQLException
getConnection in interface javax.sql.DataSourcejava.sql.SQLExceptionpublic java.sql.Connection getConnection(java.lang.String username,
java.lang.String password)
throws java.sql.SQLException
getConnection in interface javax.sql.DataSourcejava.sql.SQLExceptionpublic boolean validateConnection()
public PluginService getPluginService()
public <T> T unwrap(java.lang.Class<T> iface)
throws java.sql.SQLException
unwrap in interface java.sql.Wrapperjava.sql.SQLExceptionpublic boolean isWrapperFor(java.lang.Class<?> iface)
throws java.sql.SQLException
isWrapperFor in interface java.sql.Wrapperjava.sql.SQLExceptionpublic java.io.PrintWriter getLogWriter()
throws java.sql.SQLException
getLogWriter in interface javax.sql.CommonDataSourcejava.sql.SQLExceptionpublic void setLogWriter(java.io.PrintWriter out)
throws java.sql.SQLException
setLogWriter in interface javax.sql.CommonDataSourcejava.sql.SQLExceptionpublic void setLoginTimeout(int seconds)
throws java.sql.SQLException
setLoginTimeout in interface javax.sql.CommonDataSourcejava.sql.SQLExceptionpublic int getLoginTimeout()
throws java.sql.SQLException
getLoginTimeout in interface javax.sql.CommonDataSourcejava.sql.SQLExceptionpublic java.util.logging.Logger getParentLogger()
throws java.sql.SQLFeatureNotSupportedException
getParentLogger in interface javax.sql.CommonDataSourcejava.sql.SQLFeatureNotSupportedExceptionpublic long getConnectionRequestCount()
public long getSuccessfulConnectionCount()
public long getFailedConnectionCount()
public long getLastSuccessfulConnectionTime()
public long getLastFailedConnectionTime()
public double getConnectionSuccessRate()
public boolean isHealthy()
public java.lang.String getHealthStatus()
public void logHealthStatus()