OCILIB (C and C++ Driver for Oracle)  4.7.5
Open source and cross platform Oracle Driver delivering efficient access to Oracle databases.
Loading...
Searching...
No Matches
ocilib::Pool Class Reference

A connection or session Pool. More...

#include <types.hpp>

Inherits ocilib::core::HandleHolder< OCI_Pool * >.

Public Types

enum  PoolTypeValues { ConnectionPool = OCI_POOL_CONNECTION , SessionPool = OCI_POOL_SESSION }
 Pool type enumerated values. More...
 
typedef core::Enum< PoolTypeValuesPoolType
 Type of Pool.
 

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.
 
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.
 
void Close ()
 Destroy the current Oracle pool of connections or sessions.
 
Connection GetConnection (const ostring &sessionTag=OTEXT(""))
 Get a connection from the pool.
 
unsigned int GetTimeout () const
 Get the idle timeout for connections/sessions in the pool.
 
void SetTimeout (unsigned int value)
 Set the connections/sessions idle timeout.
 
bool GetNoWait () const
 Get the waiting mode used when no more connections/sessions are available from the pool.
 
void SetNoWait (bool value)
 Set the waiting mode used when no more connections/sessions are available from the pool.
 
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.
 
void SetStatementCacheSize (unsigned int value)
 Set the maximum number of statements to keep in the pool's statement cache.
 

Detailed Description

A connection or session Pool.

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

Definition at line 1348 of file types.hpp.

Member Typedef Documentation

◆ PoolType

Type of Pool.

Possible values are Pool::PoolTypeValues

Definition at line 1372 of file types.hpp.

Member Enumeration Documentation

◆ PoolTypeValues

Pool type enumerated values.

Enumerator
ConnectionPool 

Pool of Connections

SessionPool 

Pool of stateless sessions

Definition at line 1357 of file types.hpp.

Constructor & Destructor Documentation

◆ Pool() [1/2]

ocilib::Pool::Pool ( )
inline

Default constructor.

Definition at line 32 of file Pool.hpp.

◆ Pool() [2/2]

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 37 of file Pool.hpp.

References Open().

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 43 of file Pool.hpp.

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

Referenced by Pool().

◆ Close()

void ocilib::Pool::Close ( )
inline

Destroy the current Oracle pool of connections or sessions.

Definition at line 58 of file Pool.hpp.

◆ 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 63 of file Pool.hpp.

References ocilib::core::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 68 of file Pool.hpp.

References ocilib::core::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 73 of file Pool.hpp.

References ocilib::core::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 78 of file Pool.hpp.

References ocilib::core::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 83 of file Pool.hpp.

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

◆ GetBusyConnectionsCount()

unsigned int ocilib::Pool::GetBusyConnectionsCount ( ) const
inline

Return the current number of busy connections/sessions.

Definition at line 88 of file Pool.hpp.

References ocilib::core::Check(), and OCI_PoolGetBusyCount().

◆ GetOpenedConnectionsCount()

unsigned int ocilib::Pool::GetOpenedConnectionsCount ( ) const
inline

Return the current number of opened connections/sessions.

Definition at line 93 of file Pool.hpp.

References ocilib::core::Check(), and OCI_PoolGetOpenedCount().

◆ GetMinSize()

unsigned int ocilib::Pool::GetMinSize ( ) const
inline

Return the minimum number of connections/sessions that can be opened to the database.

Definition at line 98 of file Pool.hpp.

References ocilib::core::Check(), and OCI_PoolGetMin().

◆ GetMaxSize()

unsigned int ocilib::Pool::GetMaxSize ( ) const
inline

Return the maximum number of connections/sessions that can be opened to the database.

Definition at line 103 of file Pool.hpp.

References ocilib::core::Check(), and OCI_PoolGetMax().

◆ GetIncrement()

unsigned int ocilib::Pool::GetIncrement ( ) const
inline

Return the increment for connections/sessions to be opened to the database when the pool is not full.

Definition at line 108 of file Pool.hpp.

References ocilib::core::Check(), and OCI_PoolGetIncrement().

◆ 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 113 of file Pool.hpp.

References ocilib::core::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 118 of file Pool.hpp.

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