Package org.mariadb.jdbc.pool

## Class Pool

- java.lang.Object
- - org.mariadb.jdbc.pool.Pool

All Implemented Interfaces:
  `AutoCloseable`, `PoolMBean`

    public class Pool
    extends Object
    implements AutoCloseable, PoolMBean

### Constructor Summary

Constructors
`Pool​(Configuration conf, int poolIndex, ScheduledThreadPoolExecutor poolExecutor)` Create pool from configuration.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `close()` Close pool and underlying connections.
`long` `getActiveConnections()`
`Configuration` `getConf()`
`long` `getConnectionRequests()`
`long` `getIdleConnections()`
`InternalPoolConnection` `getPoolConnection()` Retrieve new connection.
`InternalPoolConnection` `getPoolConnection​(String username, String password)` Get new connection from pool if user and password correspond to pool.
`String` `getPoolTag()`
`long` `getTotalConnections()`
`List<Long>` `testGetConnectionIdleThreadIds()` For testing purpose only.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### Pool

    public Pool​(Configuration conf,
                int poolIndex,
                ScheduledThreadPoolExecutor poolExecutor)

Create pool from configuration.

Parameters:
  `conf` - configuration parser
  `poolIndex` - pool index to permit distinction of thread name
  `poolExecutor` - pools common executor

### Method Detail

#### getPoolConnection

    public InternalPoolConnection getPoolConnection()
                                             throws SQLException

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 InternalPoolConnection 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` - username
  `password` - password
Returns:
  connection
Throws:
  `SQLException` - if any error occur during connection

#### getConf

    public Configuration getConf()

#### close

    public void close()

Close pool and underlying connections.

Specified by:
  `close` in interface `AutoCloseable`
Throws:
  `Exception` - if interrupted

#### getPoolTag

    public String getPoolTag()

#### getActiveConnections

    public long getActiveConnections()

Specified by:
  `getActiveConnections` in interface `PoolMBean`

#### getTotalConnections

    public long getTotalConnections()

Specified by:
  `getTotalConnections` in interface `PoolMBean`

#### getIdleConnections

    public long getIdleConnections()

Specified by:
  `getIdleConnections` in interface `PoolMBean`

#### getConnectionRequests

    public long getConnectionRequests()

Specified by:
  `getConnectionRequests` in interface `PoolMBean`

#### testGetConnectionIdleThreadIds

    public List<Long> testGetConnectionIdleThreadIds()

For testing purpose only.

Returns:
  current thread id's