Class Pool
java.lang.Object
org.mariadb.jdbc.internal.util.pool.Pool
- All Implemented Interfaces:
AutoCloseable, PoolMBean
-
Constructor Summary
ConstructorsConstructorDescriptionPool(UrlParser urlParser, int poolIndex, ScheduledThreadPoolExecutor poolExecutor) Create pool from configuration. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close pool and underlying connections.booleanlongRetrieve new connection.getConnection(String username, String password) Get new connection from pool if user and password correspond to pool.longlonglonginthashCode()voidJMX method to remove state (will be reinitialized on next connection creation).For testing purpose only.
-
Constructor Details
-
Pool
Create pool from configuration.- Parameters:
urlParser- configuration parserpoolIndex- pool index to permit distinction of thread namepoolExecutor- pools common executor
-
-
Method Details
-
getConnection
Retrieve new connection. If possible return idle connection, if not, stack connection query, ask for a connection creation, and loop until a connection become idle / a new connection is created.- Returns:
- a connection object
- Throws:
SQLException- if no connection is created when reaching timeout (connectTimeout option)
-
getConnection
Get new connection from pool if user and password correspond to pool. If username and password are different from pool, will return a dedicated connection.- Parameters:
username- usernamepassword- password- Returns:
- connection
- Throws:
SQLException- if any error occur during connection
-
getUrlParser
-
close
Close pool and underlying connections.- Specified by:
closein interfaceAutoCloseable- Throws:
InterruptedException- if interrupted
-
getPoolTag
-
equals
-
hashCode
-
getGlobalInfo
-
getActiveConnections
public long getActiveConnections()- Specified by:
getActiveConnectionsin interfacePoolMBean
-
getTotalConnections
public long getTotalConnections()- Specified by:
getTotalConnectionsin interfacePoolMBean
-
getIdleConnections
public long getIdleConnections()- Specified by:
getIdleConnectionsin interfacePoolMBean
-
getConnectionRequests
public long getConnectionRequests()- Specified by:
getConnectionRequestsin interfacePoolMBean
-
testGetConnectionIdleThreadIds
-
resetStaticGlobal
public void resetStaticGlobal()JMX method to remove state (will be reinitialized on next connection creation).- Specified by:
resetStaticGlobalin interfacePoolMBean
-