public class PooledDataSource extends Object implements DataSource
Modifier and Type | Field and Description |
---|---|
protected int |
poolMaximumActiveConnections |
protected int |
poolMaximumCheckoutTime |
protected int |
poolMaximumIdleConnections |
protected int |
poolMaximumLocalBadConnectionTolerance |
protected int |
poolPingConnectionsNotUsedFor |
protected boolean |
poolPingEnabled |
protected String |
poolPingQuery |
protected int |
poolTimeToWait |
Constructor and Description |
---|
PooledDataSource() |
PooledDataSource(ClassLoader driverClassLoader,
String driver,
String url,
Properties driverProperties) |
PooledDataSource(ClassLoader driverClassLoader,
String driver,
String url,
String username,
String password) |
PooledDataSource(String driver,
String url,
Properties driverProperties) |
PooledDataSource(String driver,
String url,
String username,
String password) |
PooledDataSource(UnpooledDataSource dataSource) |
Modifier and Type | Method and Description |
---|---|
protected void |
finalize() |
void |
forceCloseAll()
Closes all active and idle connections in the pool.
|
Connection |
getConnection() |
Connection |
getConnection(String username,
String password) |
Integer |
getDefaultNetworkTimeout()
Gets the default network timeout.
|
Integer |
getDefaultTransactionIsolationLevel() |
String |
getDriver() |
Properties |
getDriverProperties() |
int |
getLoginTimeout() |
PrintWriter |
getLogWriter() |
Logger |
getParentLogger() |
String |
getPassword() |
int |
getPoolMaximumActiveConnections() |
int |
getPoolMaximumCheckoutTime() |
int |
getPoolMaximumIdleConnections() |
int |
getPoolMaximumLocalBadConnectionTolerance() |
int |
getPoolPingConnectionsNotUsedFor() |
String |
getPoolPingQuery() |
PoolState |
getPoolState() |
int |
getPoolTimeToWait() |
String |
getUrl() |
String |
getUsername() |
boolean |
isAutoCommit() |
boolean |
isPoolPingEnabled() |
boolean |
isWrapperFor(Class<?> iface) |
protected boolean |
pingConnection(org.apache.ibatis.datasource.pooled.PooledConnection conn)
Method to check to see if a connection is still usable
|
protected void |
pushConnection(org.apache.ibatis.datasource.pooled.PooledConnection conn) |
void |
setDefaultAutoCommit(boolean defaultAutoCommit) |
void |
setDefaultNetworkTimeout(Integer milliseconds)
Sets the default network timeout value to wait for the database operation to complete.
|
void |
setDefaultTransactionIsolationLevel(Integer defaultTransactionIsolationLevel) |
void |
setDriver(String driver) |
void |
setDriverProperties(Properties driverProps) |
void |
setLoginTimeout(int loginTimeout) |
void |
setLogWriter(PrintWriter logWriter) |
void |
setPassword(String password) |
void |
setPoolMaximumActiveConnections(int poolMaximumActiveConnections)
The maximum number of active connections.
|
void |
setPoolMaximumCheckoutTime(int poolMaximumCheckoutTime)
The maximum time a connection can be used before it *may* be
given away again.
|
void |
setPoolMaximumIdleConnections(int poolMaximumIdleConnections)
The maximum number of idle connections.
|
void |
setPoolMaximumLocalBadConnectionTolerance(int poolMaximumLocalBadConnectionTolerance)
The maximum number of tolerance for bad connection happens in one thread
which are applying for new
PooledConnection . |
void |
setPoolPingConnectionsNotUsedFor(int milliseconds)
If a connection has not been used in this many milliseconds, ping the
database to make sure the connection is still good.
|
void |
setPoolPingEnabled(boolean poolPingEnabled)
Determines if the ping query should be used.
|
void |
setPoolPingQuery(String poolPingQuery)
The query to be used to check a connection.
|
void |
setPoolTimeToWait(int poolTimeToWait)
The time to wait before retrying to get a connection.
|
void |
setUrl(String url) |
void |
setUsername(String username) |
<T> T |
unwrap(Class<T> iface) |
static Connection |
unwrapConnection(Connection conn)
Unwraps a pooled connection to get to the 'real' connection
|
protected int poolMaximumActiveConnections
protected int poolMaximumIdleConnections
protected int poolMaximumCheckoutTime
protected int poolTimeToWait
protected int poolMaximumLocalBadConnectionTolerance
protected String poolPingQuery
protected boolean poolPingEnabled
protected int poolPingConnectionsNotUsedFor
public PooledDataSource()
public PooledDataSource(UnpooledDataSource dataSource)
public PooledDataSource(String driver, String url, String username, String password)
public PooledDataSource(String driver, String url, Properties driverProperties)
public PooledDataSource(ClassLoader driverClassLoader, String driver, String url, String username, String password)
public PooledDataSource(ClassLoader driverClassLoader, String driver, String url, Properties driverProperties)
public Connection getConnection() throws SQLException
getConnection
in interface DataSource
SQLException
public Connection getConnection(String username, String password) throws SQLException
getConnection
in interface DataSource
SQLException
public void setLoginTimeout(int loginTimeout)
setLoginTimeout
in interface CommonDataSource
public int getLoginTimeout()
getLoginTimeout
in interface CommonDataSource
public void setLogWriter(PrintWriter logWriter)
setLogWriter
in interface CommonDataSource
public PrintWriter getLogWriter()
getLogWriter
in interface CommonDataSource
public void setDriver(String driver)
public void setUrl(String url)
public void setUsername(String username)
public void setPassword(String password)
public void setDefaultAutoCommit(boolean defaultAutoCommit)
public void setDefaultTransactionIsolationLevel(Integer defaultTransactionIsolationLevel)
public void setDriverProperties(Properties driverProps)
public void setDefaultNetworkTimeout(Integer milliseconds)
Connection.setNetworkTimeout(java.util.concurrent.Executor, int)
milliseconds
- The time in milliseconds to wait for the database operation to complete.public void setPoolMaximumActiveConnections(int poolMaximumActiveConnections)
poolMaximumActiveConnections
- The maximum number of active connectionspublic void setPoolMaximumIdleConnections(int poolMaximumIdleConnections)
poolMaximumIdleConnections
- The maximum number of idle connectionspublic void setPoolMaximumLocalBadConnectionTolerance(int poolMaximumLocalBadConnectionTolerance)
PooledConnection
.poolMaximumLocalBadConnectionTolerance
- max tolerance for bad connection happens in one threadpublic void setPoolMaximumCheckoutTime(int poolMaximumCheckoutTime)
poolMaximumCheckoutTime
- The maximum timepublic void setPoolTimeToWait(int poolTimeToWait)
poolTimeToWait
- The time to waitpublic void setPoolPingQuery(String poolPingQuery)
poolPingQuery
- The querypublic void setPoolPingEnabled(boolean poolPingEnabled)
poolPingEnabled
- True if we need to check a connection before using itpublic void setPoolPingConnectionsNotUsedFor(int milliseconds)
milliseconds
- the number of milliseconds of inactivity that will trigger a pingpublic String getDriver()
public String getUrl()
public String getUsername()
public String getPassword()
public boolean isAutoCommit()
public Integer getDefaultTransactionIsolationLevel()
public Properties getDriverProperties()
public Integer getDefaultNetworkTimeout()
public int getPoolMaximumActiveConnections()
public int getPoolMaximumIdleConnections()
public int getPoolMaximumLocalBadConnectionTolerance()
public int getPoolMaximumCheckoutTime()
public int getPoolTimeToWait()
public String getPoolPingQuery()
public boolean isPoolPingEnabled()
public int getPoolPingConnectionsNotUsedFor()
public void forceCloseAll()
public PoolState getPoolState()
protected void pushConnection(org.apache.ibatis.datasource.pooled.PooledConnection conn) throws SQLException
SQLException
protected boolean pingConnection(org.apache.ibatis.datasource.pooled.PooledConnection conn)
conn
- - the connection to checkpublic static Connection unwrapConnection(Connection conn)
conn
- - the pooled connection to unwrapprotected void finalize() throws Throwable
public <T> T unwrap(Class<T> iface) throws SQLException
unwrap
in interface Wrapper
SQLException
public boolean isWrapperFor(Class<?> iface)
isWrapperFor
in interface Wrapper
public Logger getParentLogger()
getParentLogger
in interface CommonDataSource
Copyright © 2009–2021 MyBatis.org. All rights reserved.