Oracle® Objects for OLE C++ Class Library Developer's Guide 10g Release 2 (10.2) B14308-01 |
|
Creating the Connection Pool
The Odatabase() method (OpenDatabase method) of the OSession object is used to establish a connection to an Oracle database. The Connection Pool in OO4O is a pool of ODatabase objects. The pool is created by invoking the CreateDatabasePool() method of the Osession() interface.
Obtaining and returning elements to and from the pool
To retrieve an ODatabase object from the pool, the GetDatabaseFromPool() method is called. This function returns a reference to an ODatabase object.
Destroying the pool
The pool is implicitly destroyed if the parent session object that it belong to is destroyed. It can also be destroyed at any time by invoking the DestroyDatabasePool() method.
Accessing the Pool attributes
The following are the Database Pool Properties. These properties are read-only.
long OSession::GetDbPoolMaxSize() const; // Maximum Pool Size
long OSession::GetDbPoolCurrentSize() const; // Current Size of the Pool
long OSession::GetDbPoolInitialSize() const; // Initial Size of the Pool
Doing Transaction processing using the Database from the Connection Pool
This is the recommended way of doing transactions:
Odb = OSession.GetDatabaseFromPool(10);
Oconn = Odb.GetConnection();
Oconn.BeginTransaction();
//Do processing here…
Oconn.Commit();