public abstract class AbstractDataSourceBean extends java.lang.Object implements javax.sql.DataSource, ConnectionPoolProperties, javax.naming.Referenceable, java.io.Serializable
DEFAULT_BORROW_CONNECTION_TIMEOUT, DEFAULT_ISOLATION_LEVEL_UNSET, DEFAULT_MAINTENANCE_INTERVAL, DEFAULT_MAX_IDLE_TIME, DEFAULT_MAX_LIFETIME, DEFAULT_POOL_SIZE, DEFAULT_REAP_TIMEOUT| Constructor and Description |
|---|
AbstractDataSourceBean() |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
protected abstract void |
doClose() |
protected abstract ConnectionFactory<java.sql.Connection> |
doInit() |
int |
getBorrowConnectionTimeout()
Get the maximum amount of time in seconds the pool will block
waiting for a connection to become available in the pool when it
is empty.
|
boolean |
getConcurrentConnectionValidation() |
java.sql.Connection |
getConnection() |
java.sql.Connection |
getConnection(java.lang.String username,
java.lang.String password) |
int |
getDefaultIsolationLevel()
Gets the default isolation level for connections created by this datasource.
|
boolean |
getLocalTransactionMode()
Tests whether local transactions are allowed - defaults to false
for JDBC.
|
int |
getLoginTimeout() |
java.io.PrintWriter |
getLogWriter() |
int |
getMaintenanceInterval()
Gets the maintenance interval as set.
|
int |
getMaxIdleTime()
Gets the maximum amount of time in seconds a connection can stay in the pool
before being eligible for being closed during pool shrinking.
|
int |
getMaxLifetime()
Gets the maximum lifetime in seconds.
|
int |
getMaxPoolSize()
Get the maximum pool size.
|
int |
getMinPoolSize()
Gets the minimum size of the pool.
|
java.util.logging.Logger |
getParentLogger()
JDK 1.7 requirement.
|
int |
getReapTimeout()
Get the amount of time in seconds the connection pool will allow a connection
to be borrowed before claiming it back.
|
javax.naming.Reference |
getReference() |
java.lang.String |
getTestQuery()
Gets the SQL query used to test a connection before returning it.
|
java.lang.String |
getUniqueResourceName()
Get the resource name.
|
void |
init() |
protected abstract boolean |
isAssignableFromWrappedVendorClass(java.lang.Class<?> iface) |
boolean |
isWrapperFor(java.lang.Class<?> iface) |
int |
poolAvailableSize() |
int |
poolTotalSize() |
void |
refreshPool()
Refreshes all available connections in the pool.
|
void |
setBorrowConnectionTimeout(int borrowConnectionTimeout)
Sets the maximum amount of time in seconds the pool will block
waiting for a connection to become available in the pool when it
is empty.
|
void |
setConcurrentConnectionValidation(boolean value)
Sets whether or not to use concurrent connection validation.
|
void |
setDefaultIsolationLevel(int defaultIsolationLevel)
Sets the default isolation level of connections returned by this datasource.
|
void |
setLoginTimeout(int seconds) |
void |
setLogWriter(java.io.PrintWriter out) |
void |
setMaintenanceInterval(int maintenanceInterval)
Sets the maintenance interval for the pool maintenance thread.
|
void |
setMaxIdleTime(int maxIdleTime)
Sets the maximum amount of seconds that unused excess connections should stay in the pool.
|
void |
setMaxLifetime(int maxLifetime)
Sets the maximum amount of seconds that a connection is kept in the pool before
it is destroyed automatically.
|
void |
setMaxPoolSize(int maxPoolSize)
Sets the maximum pool size.
|
void |
setMinPoolSize(int minPoolSize)
Sets the minimum pool size.
|
void |
setPoolSize(int poolSize)
Sets both the minimal and maximal pool size.
|
void |
setReapTimeout(int reapTimeout)
Sets the amount of time (in seconds) that the connection pool will allow a connection
to be in use, before claiming it back.
|
void |
setTestQuery(java.lang.String testQuery)
Sets the SQL query or statement used to validate a connection before returning it.
|
void |
setUniqueResourceName(java.lang.String resourceName)
Sets the resource name.
|
protected void |
throwAtomikosSQLException(java.lang.String msg) |
<T> T |
unwrap(java.lang.Class<T> iface) |
protected abstract java.lang.Object |
unwrapVendorInstance() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetIgnoreJtaTransactionsprotected void throwAtomikosSQLException(java.lang.String msg)
throws AtomikosSQLException
AtomikosSQLExceptionpublic int getMinPoolSize()
getMinPoolSize in interface ConnectionPoolPropertiespublic void setMinPoolSize(int minPoolSize)
minPoolSize - public int getMaxPoolSize()
getMaxPoolSize in interface ConnectionPoolPropertiespublic void setMaxPoolSize(int maxPoolSize)
maxPoolSize - public void setPoolSize(int poolSize)
public int getBorrowConnectionTimeout()
getBorrowConnectionTimeout in interface ConnectionPoolPropertiespublic void setBorrowConnectionTimeout(int borrowConnectionTimeout)
borrowConnectionTimeout - The time in seconds. Zero or negative means no waiting at all.
Defaults to 30 seconds.public int getReapTimeout()
getReapTimeout in interface ConnectionPoolPropertiespublic void setReapTimeout(int reapTimeout)
reapTimeout - The timeout in seconds. Zero means unlimited. Note that this value is
only an indication; the pool will check regularly as indicated by the maintenanceInteval property.
Defaults to maxLifetime.public void setMaintenanceInterval(int maintenanceInterval)
maintenanceInterval - The interval in seconds. If not set or not positive then the pool's default (60 secs) will be used.public int getMaintenanceInterval()
getMaintenanceInterval in interface ConnectionPoolPropertiespublic int getMaxIdleTime()
getMaxIdleTime in interface ConnectionPoolPropertiespublic void setMaxIdleTime(int maxIdleTime)
maxIdleTime - The preferred idle time for unused excess connections. Note that this value is
only an indication; the pool will check regularly as indicated by the maintenanceInteval property.
The default is 60 seconds.public void setMaxLifetime(int maxLifetime)
maxLifetime - public int getMaxLifetime()
getMaxLifetime in interface ConnectionPoolPropertiespublic java.lang.String getTestQuery()
getTestQuery in interface ConnectionPoolPropertiespublic void setTestQuery(java.lang.String testQuery)
testQuery - - The SQL query or statement to validate the connection with. Note that
although you can specify updates here, these will NOT be part of any JTA transaction!public void setConcurrentConnectionValidation(boolean value)
value - public boolean getConcurrentConnectionValidation()
public int poolAvailableSize()
public int poolTotalSize()
public java.io.PrintWriter getLogWriter()
throws java.sql.SQLException
getLogWriter in interface javax.sql.CommonDataSourcejava.sql.SQLExceptionpublic int getLoginTimeout()
throws java.sql.SQLException
getLoginTimeout 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 void init()
throws AtomikosSQLException
AtomikosSQLExceptionpublic void close()
protected abstract ConnectionFactory<java.sql.Connection> doInit() throws java.lang.Exception
java.lang.Exceptionprotected abstract void doClose()
public 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 java.lang.String getUniqueResourceName()
getUniqueResourceName in interface ConnectionPoolPropertiespublic void setUniqueResourceName(java.lang.String resourceName)
resourceName - An arbitrary user-specified value that identifies
this datasource. It must be unique for recovery purposes.public boolean getLocalTransactionMode()
getLocalTransactionMode in interface ConnectionPoolPropertiespublic javax.naming.Reference getReference()
throws javax.naming.NamingException
getReference in interface javax.naming.Referenceablejavax.naming.NamingExceptionpublic void setDefaultIsolationLevel(int defaultIsolationLevel)
defaultIsolationLevel - The default isolation level.
Negative values are ignored and result in vendor-specific JDBC driver or DBMS internal defaults.public int getDefaultIsolationLevel()
getDefaultIsolationLevel in interface ConnectionPoolPropertiespublic boolean isWrapperFor(java.lang.Class<?> iface)
isWrapperFor in interface java.sql.Wrapperprotected abstract boolean isAssignableFromWrappedVendorClass(java.lang.Class<?> iface)
public <T> T unwrap(java.lang.Class<T> iface)
throws java.sql.SQLException
unwrap in interface java.sql.Wrapperjava.sql.SQLExceptionprotected abstract java.lang.Object unwrapVendorInstance()
public java.util.logging.Logger getParentLogger()
throws java.sql.SQLFeatureNotSupportedException
getParentLogger in interface javax.sql.CommonDataSourcejava.sql.SQLFeatureNotSupportedExceptionpublic void refreshPool()
Copyright © 2019. All Rights Reserved.