OCILIB (C and C++ Driver for Oracle)
4.7.5
Open source and cross platform Oracle Driver delivering efficient access to Oracle databases.
|
OcilibCApiConnections
OCILIB support the connections and sessions pooling features introduced in Oracle 9i.
Let's Oracle talk about this features !
Connection pooling is the use of a group (the pool) of reusable physical connections by several sessions, in order to balance loads. The management of the pool is done by OCI, not the application. Applications that can use connection pooling include middle-tier applications for Web application servers and e-mail servers.
Session pooling means that the application will create and maintain a group of stateless sessions to the database. These sessions will be handed over to thin clients as requested. If no sessions are available, a new one may be created. When the client is done with the session, the client will release it to the pool. Thus, the number of sessions in the pool can increase dynamically.
If database sessions are not reusable by mid-tier threads (that is, they are stateful) and the number of back-end server processes may cause scaling problems on the database, use OCI connection pooling.
If database sessions are reusable by mid-tier threads (that is, they are stateless) and the number of back-end server processes may cause scaling problems on the database, use OCI session pooling.
If database sessions are not reusable by mid-tier threads (that is, they are stateful) and the number of back-end server processes will never be large enough to potentially cause any scaling issue on the database, there is no need to use any pooling mechanism.
Functions | |
OCI_SYM_PUBLIC OCI_Pool *OCI_API | OCI_PoolCreate (const otext *db, const otext *user, const otext *pwd, unsigned int type, unsigned int mode, unsigned int min_con, unsigned int max_con, unsigned int incr_con) |
Create an Oracle pool of connections or sessions. | |
OCI_SYM_PUBLIC boolean OCI_API | OCI_PoolFree (OCI_Pool *pool) |
Destroy a pool object. | |
OCI_SYM_PUBLIC OCI_Connection *OCI_API | OCI_PoolGetConnection (OCI_Pool *pool, const otext *tag) |
Get a connection from the pool. | |
OCI_SYM_PUBLIC unsigned int OCI_API | OCI_PoolGetTimeout (OCI_Pool *pool) |
Get the idle timeout for connections/sessions in the pool. | |
OCI_SYM_PUBLIC boolean OCI_API | OCI_PoolSetTimeout (OCI_Pool *pool, unsigned int value) |
Set the connections/sessions idle timeout. | |
OCI_SYM_PUBLIC boolean OCI_API | OCI_PoolGetNoWait (OCI_Pool *pool) |
Get the waiting mode used when no more connections/sessions are available from the pool. | |
OCI_SYM_PUBLIC boolean OCI_API | OCI_PoolSetNoWait (OCI_Pool *pool, boolean value) |
Set the waiting mode used when no more connections/sessions are available from the pool. | |
OCI_SYM_PUBLIC unsigned int OCI_API | OCI_PoolGetBusyCount (OCI_Pool *pool) |
Return the current number of busy connections/sessions. | |
OCI_SYM_PUBLIC unsigned int OCI_API | OCI_PoolGetOpenedCount (OCI_Pool *pool) |
Return the current number of opened connections/sessions. | |
OCI_SYM_PUBLIC unsigned int OCI_API | OCI_PoolGetMin (OCI_Pool *pool) |
Return the minimum number of connections/sessions that can be opened to the database. | |
OCI_SYM_PUBLIC unsigned int OCI_API | OCI_PoolGetMax (OCI_Pool *pool) |
Return the maximum number of connections/sessions that can be opened to the database. | |
OCI_SYM_PUBLIC unsigned int OCI_API | OCI_PoolGetIncrement (OCI_Pool *pool) |
Return the increment for connections/sessions to be opened to the database when the pool is not full. | |
OCI_SYM_PUBLIC unsigned int OCI_API | OCI_PoolGetStatementCacheSize (OCI_Pool *pool) |
Return the maximum number of statements to keep in the pool statement cache. | |
OCI_SYM_PUBLIC boolean OCI_API | OCI_PoolSetStatementCacheSize (OCI_Pool *pool, unsigned int value) |
Set the maximum number of statements to keep in the pool statement cache. | |
OCI_SYM_PUBLIC OCI_Pool *OCI_API OCI_PoolCreate | ( | const otext * | db, |
const otext * | user, | ||
const otext * | pwd, | ||
unsigned int | type, | ||
unsigned int | mode, | ||
unsigned int | min_con, | ||
unsigned int | max_con, | ||
unsigned int | incr_con | ||
) |
#include <api.h>
Create an Oracle pool of connections or sessions.
db | - Oracle Service Name |
user | - Oracle User name |
pwd | - Oracle User password |
type | - Type of pool |
mode | - Session mode |
min_con | - minimum number of connections/sessions that can be opened. |
max_con | - maximum number of connections/sessions that can be opened. |
incr_con | - next increment for connections/sessions to be opened |
Possible values for parameter 'type':
Possible values for parameter 'mode':
Referenced by ocilib::Pool::Open().
OCI_SYM_PUBLIC boolean OCI_API OCI_PoolFree | ( | OCI_Pool * | pool | ) |
#include <api.h>
Destroy a pool object.
pool | - Pool handle |
OCI_SYM_PUBLIC OCI_Connection *OCI_API OCI_PoolGetConnection | ( | OCI_Pool * | pool, |
const otext * | tag | ||
) |
#include <api.h>
Get a connection from the pool.
pool | - Pool handle |
tag | - user tag string |
Session pools have a nice feature that is '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"
Referenced by ocilib::Pool::GetConnection().
OCI_SYM_PUBLIC unsigned int OCI_API OCI_PoolGetTimeout | ( | OCI_Pool * | pool | ) |
#include <api.h>
Get the idle timeout for connections/sessions in the pool.
pool | - Pool handle |
Referenced by ocilib::Pool::GetTimeout().
OCI_SYM_PUBLIC boolean OCI_API OCI_PoolSetTimeout | ( | OCI_Pool * | pool, |
unsigned int | value | ||
) |
#include <api.h>
Set the connections/sessions idle timeout.
pool | - Pool handle |
value | - Timeout value |
Referenced by ocilib::Pool::SetTimeout().
OCI_SYM_PUBLIC boolean OCI_API OCI_PoolGetNoWait | ( | OCI_Pool * | pool | ) |
#include <api.h>
Get the waiting mode used when no more connections/sessions are available from the pool.
pool | - Pool handle |
Referenced by ocilib::Pool::GetNoWait().
OCI_SYM_PUBLIC boolean OCI_API OCI_PoolSetNoWait | ( | OCI_Pool * | pool, |
boolean | value | ||
) |
#include <api.h>
Set the waiting mode used when no more connections/sessions are available from the pool.
pool | - Pool handle |
value | - wait for object |
Referenced by ocilib::Pool::SetNoWait().
OCI_SYM_PUBLIC unsigned int OCI_API OCI_PoolGetBusyCount | ( | OCI_Pool * | pool | ) |
#include <api.h>
Return the current number of busy connections/sessions.
pool | - Pool handle |
Referenced by ocilib::Pool::GetBusyConnectionsCount().
OCI_SYM_PUBLIC unsigned int OCI_API OCI_PoolGetOpenedCount | ( | OCI_Pool * | pool | ) |
#include <api.h>
Return the current number of opened connections/sessions.
pool | - Pool handle |
Referenced by ocilib::Pool::GetOpenedConnectionsCount().
OCI_SYM_PUBLIC unsigned int OCI_API OCI_PoolGetMin | ( | OCI_Pool * | pool | ) |
#include <api.h>
Return the minimum number of connections/sessions that can be opened to the database.
pool | - Pool handle |
Referenced by ocilib::Pool::GetMinSize().
OCI_SYM_PUBLIC unsigned int OCI_API OCI_PoolGetMax | ( | OCI_Pool * | pool | ) |
#include <api.h>
Return the maximum number of connections/sessions that can be opened to the database.
pool | - Pool handle |
Referenced by ocilib::Pool::GetMaxSize().
OCI_SYM_PUBLIC unsigned int OCI_API OCI_PoolGetIncrement | ( | OCI_Pool * | pool | ) |
#include <api.h>
Return the increment for connections/sessions to be opened to the database when the pool is not full.
pool | - Pool handle |
Referenced by ocilib::Pool::GetIncrement().
OCI_SYM_PUBLIC unsigned int OCI_API OCI_PoolGetStatementCacheSize | ( | OCI_Pool * | pool | ) |
#include <api.h>
Return the maximum number of statements to keep in the pool statement cache.
pool | - Pool handle |
Referenced by ocilib::Pool::GetStatementCacheSize().
OCI_SYM_PUBLIC boolean OCI_API OCI_PoolSetStatementCacheSize | ( | OCI_Pool * | pool, |
unsigned int | value | ||
) |
#include <api.h>
Set the maximum number of statements to keep in the pool statement cache.
pool | - Pool handle |
value | - maximum number of statements in the cache |
Referenced by ocilib::Pool::SetStatementCacheSize().