Package org.mariadb.jdbc.pool
Class Pool
java.lang.Object
org.mariadb.jdbc.pool.Pool
- All Implemented Interfaces:
AutoCloseable,PoolMBean
MariaDB Pool
-
Constructor Summary
ConstructorsConstructorDescriptionPool(Configuration conf, int poolIndex, ScheduledThreadPoolExecutor poolExecutor) Create pool from configuration. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close pool and underlying connections.longget pool active connection numbergetConf()Get current configurationlongget connection waiting request numberlongget idle connection numberRetrieve new connection.getPoolConnection(String username, String password) Get new connection from pool if user and password correspond to pool.return pool taglongget pool total connectionFor testing purpose only.
-
Constructor Details
-
Pool
Create pool from configuration.- Parameters:
conf- configuration parserpoolIndex- pool index to permit distinction of thread namepoolExecutor- pools common executor
-
-
Method Details
-
getPoolConnection
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)
-
getPoolConnection
public MariaDbInnerPoolConnection getPoolConnection(String username, String password) throws SQLException 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
-
getConf
Get current configuration- Returns:
- configuration
-
close
public void close()Close pool and underlying connections.- Specified by:
closein interfaceAutoCloseable
-
getPoolTag
return pool tag- Returns:
- pool tag
-
getActiveConnections
public long getActiveConnections()Description copied from interface:PoolMBeanget pool active connection number- Specified by:
getActiveConnectionsin interfacePoolMBean- Returns:
- pool active connection number
-
getTotalConnections
public long getTotalConnections()Description copied from interface:PoolMBeanget pool total connection- Specified by:
getTotalConnectionsin interfacePoolMBean- Returns:
- pool total connection number
-
getIdleConnections
public long getIdleConnections()Description copied from interface:PoolMBeanget idle connection number- Specified by:
getIdleConnectionsin interfacePoolMBean- Returns:
- idle connection number
-
getConnectionRequests
public long getConnectionRequests()Description copied from interface:PoolMBeanget connection waiting request number- Specified by:
getConnectionRequestsin interfacePoolMBean- Returns:
- request number
-
testGetConnectionIdleThreadIds
For testing purpose only.- Returns:
- current thread id's
-