ocilib::Pool Class Reference

A connection or session Pool. More...

`#include <ocilib.hpp>`

Inherits ocilib::HandleHolder< OCI_Pool *>.

## Public Types

enum | PoolTypeValues { ConnectionPool = OCI_POOL_CONNECTION, SessionPool = OCI_POOL_SESSION }
| Pool type enumerated values. More...
typedef Enum< PoolTypeValues > | PoolType
| Type of Pool. More...

## Public Member Functions

| Pool ()
| Default constructor.
| Pool (const ostring &db, const ostring &user, const ostring &pwd, Pool::PoolType poolType, unsigned int minSize, unsigned int maxSize, unsigned int increment=1, Environment::SessionFlags sessionFlags=Environment::SessionDefault)
| Constructor that creates an underlying pool with the given information. More...
void | Open (const ostring &db, const ostring &user, const ostring &pwd, Pool::PoolType poolType, unsigned int minSize, unsigned int maxSize, unsigned int increment=1, Environment::SessionFlags sessionFlags=Environment::SessionDefault)
| Create an Oracle pool of connections or sessions. More...
void | Close ()
| Destroy the current Oracle pool of connections or sessions.
Connection | GetConnection (const ostring &sessionTag=OTEXT(""))
| Get a connection from the pool. More...
unsigned int | GetTimeout () const
| Get the idle timeout for connections/sessions in the pool. More...
void | SetTimeout (unsigned int value)
| Set the connections/sessions idle timeout. More...
bool | GetNoWait () const
| Get the waiting mode used when no more connections/sessions are available from the pool. More...
void | SetNoWait (bool value)
| Set the waiting mode used when no more connections/sessions are available from the pool. More...
unsigned int | GetBusyConnectionsCount () const
| Return the current number of busy connections/sessions.
unsigned int | GetOpenedConnectionsCount () const
| Return the current number of opened connections/sessions.
unsigned int | GetMinSize () const
| Return the minimum number of connections/sessions that can be opened to the database.
unsigned int | GetMaxSize () const
| Return the maximum number of connections/sessions that can be opened to the database.
unsigned int | GetIncrement () const
| Return the increment for connections/sessions to be opened to the database when the pool is not full.
unsigned int | GetStatementCacheSize () const
| Return the maximum number of statements to keep in the pool's statement cache. More...
void | SetStatementCacheSize (unsigned int value)
| Set the maximum number of statements to keep in the pool's statement cache. More...

## Detailed Description

A connection or session Pool.

This class wraps the OCILIB object handle OCI_Pool and its related methods

Definition at line 1437 of file ocilib.hpp.

## Member Typedef Documentation

## PoolType

typedef Enum<PoolTypeValues> ocilib::Pool::PoolType

Type of Pool.

Possible values are Pool::PoolTypeValues

Definition at line 1461 of file ocilib.hpp.

## Member Enumeration Documentation

## PoolTypeValues

enum ocilib::Pool::PoolTypeValues

Pool type enumerated values.

Enumerator
ConnectionPool | Pool of Connections
SessionPool | Pool of stateless sessions

Definition at line 1446 of file ocilib.hpp.

## Constructor & Destructor Documentation

## Pool()

ocilib::Pool::Pool | ( | const ostring & | db,
|  | const ostring & | user,
|  | const ostring & | pwd,
|  | Pool::PoolType | poolType,
|  | unsigned int | minSize,
|  | unsigned int | maxSize,
|  | unsigned int | increment = `1`,
|  | Environment::SessionFlags | sessionFlags = `Environment::SessionDefault`
| ) |  |

inline

Constructor that creates an underlying pool with the given information.

Parameters

  db | - Oracle Service Name
  user | - Oracle User name
  pwd | - Oracle User password
  poolType | - Type of pool
  sessionFlags | - session Flags
  minSize | - minimum number of connections/sessions that can be opened.
  maxSize | - maximum number of connections/sessions that can be opened.
  increment | - next increment for connections/sessions to be opened

Note
  it calls Open() with the given parameters

Definition at line 1317 of file ocilib_impl.hpp.

## Member Function Documentation

## Open()

void ocilib::Pool::Open | ( | const ostring & | db,
|  | const ostring & | user,
|  | const ostring & | pwd,
|  | Pool::PoolType | poolType,
|  | unsigned int | minSize,
|  | unsigned int | maxSize,
|  | unsigned int | increment = `1`,
|  | Environment::SessionFlags | sessionFlags = `Environment::SessionDefault`
| ) |  |

inline

Create an Oracle pool of connections or sessions.

Parameters

  db | - Oracle Service Name
  user | - Oracle User name
  pwd | - Oracle User password
  poolType | - Type of pool
  sessionFlags | - session Flags
  minSize | - minimum number of connections/sessions that can be opened.
  maxSize | - maximum number of connections/sessions that can be opened.
  increment | - next increment for connections/sessions to be opened

Note
  External credentials are supported by supplying an empty string for the 'user' and 'pwd' parameters If the param 'db' is empty then a connection to the default local DB is done

Definition at line 1323 of file ocilib_impl.hpp.

References ocilib::Check(), OCI_PoolCreate(), and OCI_PoolFree().

## GetConnection()

Connection ocilib::Pool::GetConnection | ( | const ostring & | sessionTag = `OTEXT("")` | ) |

inline

Get a connection from the pool.

Parameters

  sessionTag | - Session user tag string

Session tagging

Session pools have a nice feature called 'session tagging' It's possible to tag a session with a string identifier when the session is returned to the pool, it keeps its tags. When requesting a connection from the session pool, it's possible to request a session that has the given 'tag' parameter If one exists, it is returned. If not and if an untagged session is available, it is then returned. So check the connection tag property with OCI_GetSessionTag() to find out if the returned connection is tagged or not.

This features is described in the OCI developer guide as the following :

"The tags provide a way for users to customize sessions in the pool. A client may get a default or untagged session from a pool, set certain attributes on the session (such as NLS settings), and return the session to the pool, labeling it with an appropriate tag. The user may request a session with the same tags in order to have a session with the same attributes"

Definition at line 1337 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_PoolGetConnection().

## GetTimeout()

unsigned int ocilib::Pool::GetTimeout | ( |  | ) | const

inline

Get the idle timeout for connections/sessions in the pool.

Note
  Connections/sessions idled for more than this time value (in seconds) are terminated
  Timeout is not available for internal pooling implementation (client < 9i)

Definition at line 1342 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_PoolGetTimeout().

## SetTimeout()

void ocilib::Pool::SetTimeout | ( | unsigned int | value | ) |

inline

Set the connections/sessions idle timeout.

Parameters

  value | - Timeout value

Note
  connections/sessions idle for more than this time value (in seconds) are terminated
  This call has no effect if pooling is internally implemented (client < 9i)

Definition at line 1347 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_PoolSetTimeout().

## GetNoWait()

bool ocilib::Pool::GetNoWait | ( |  | ) | const

inline

Get the waiting mode used when no more connections/sessions are available from the pool.

Returns
  - true to wait for an available object if the pool is saturated
  - false to not wait for an available object

Definition at line 1352 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_PoolGetNoWait().

## SetNoWait()

void ocilib::Pool::SetNoWait | ( | bool | value | ) |

inline

Set the waiting mode used when no more connections/sessions are available from the pool.

Parameters

  value | - wait for object

Note
  For parameter value, pass :
  - true to wait for an available object if the pool is saturated
  - false to not wait for an available object

Definition at line 1357 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_PoolSetNoWait().

## GetStatementCacheSize()

unsigned int ocilib::Pool::GetStatementCacheSize | ( |  | ) | const

inline

Return the maximum number of statements to keep in the pool's statement cache.

Note
  Default value is 20 (value from Oracle Documentation)

Definition at line 1387 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_PoolGetStatementCacheSize().

## SetStatementCacheSize()

void ocilib::Pool::SetStatementCacheSize | ( | unsigned int | value | ) |

inline

Set the maximum number of statements to keep in the pool's statement cache.

Parameters

  value | - maximum number of statements in the cache

Definition at line 1392 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_PoolSetStatementCacheSize().