Oracle C++ Call Interface Programmer's Guide Release 2 (9.2) Part Number A96583-01 |
|
OCCI Classes and Methods, 9 of 22
The Environment class provides an OCCI environment to manage memory and other resources for OCCI objects.
The application can have multiple OCCI environments. Each environment would have its own heap and thread-safety mutexes and so forth.
To create an Environment
object, use the syntax:
Environment() enum Mode { DEFAULT = OCI_DEFAULT, OBJECT = OCI_OBJECT, SHARED = OCI_SHARED, NO_USERCALLBACKS = OCI_NO_UCB, THREADED_MUTEXED = OCI_THREADED, THREADED_UNMUTEXED = OCI_THREADED | OCI_ENV_NO_MUTEX };
This method establishes a connection to the database specified.
Connection * createConnection(const string &username, const string &password, const string &connectString);
The name of the user to connect as.
The password of the user.
The database to connect to.
This method creates a connection pool based on the parameters specified.
ConnectionPool* createConnectionPool(const string &poolUserName, const string &poolPassword, const string &connectString = "", unsigned int minConn = 0, unsigned int maxConn = 1, unsigned int incrConn = 1);
The pool user name.
The pool password.
The database to connect to.
The minimum number of connections in the pool. The minimum number of connections are opened by this method. Additional connections are opened only when necessary. Generally, minConn
should be set to the number of concurrent statements the application is expected to run.
The maximum number of connections in the pool.
Valid values are 1 and greater.
The increment by which to increase the number of connections to be opened if the current number of connections is less than connMax
.
Valid values are 1 and greater.
This method creates an Environment
object. It is created with the specified memory management functions specified in the setMemMgrFunctions()
method. If no memory manager functions are specified, then OCCI uses its own default functions. An Environment
object must eventually be closed to free all the system resources it has acquired.
If the mode specified is THREADED_MUTEXED or THREADED_UN_MUTEXED, then all three memory management functions must be thread-safe.
static Environment * createEnvironment(Mode mode = DEFAULT, void *ctxp = 0, void *(*malocfp)(void *ctxp, size_t size) = 0, void *(*ralocfp)(void *ctxp, void *memptr, size_t newsize) = 0, void (*mfreefp)(void *ctxp, void *memptr) = 0);
Valid values are:
DEFAULT not thread safe, not in object mode
THREADED_MUTEXED thread safe, mutexed internally by OCCI
THREADED_UN-MUTEXTED thread safe, client responsible for mutexing
OBJECT uses object features
Context pointer for user-defined memory management function.
The size of the memory to be allocated by user-defined memory allocation function.
User-defined memory allocation function.
User-defined memory reallocation function.
User-defined memory free function.
This method retrieves the Cache Max heap size.
unsigned int getCacheMaxSize() const;
This method retrieves the Cache optimal heap size.
unsigned int getCacheOptSize() const;
This method returns the amount of memory currently allocated to all objects in this environment.
unsigned int getCurrentHeapSize() const;
This method returns a pointer to the map for this environment.
Map *getMap() const;
This method returns a pointer to the OCI environment associated with this environment.
LNOCIEnv *getOCIEnvironment() const;
This method sets the maximum size for the client-side object cache as a percentage of the optimal size. The default value is 10%.
void setCacheMaxSize(unsigned int maxsize);
The value of the maximum size, expressed as a percentage.
This method sets the optimal size for the client-side object cache in bytes. The default value is 8MB.
void setCacheOptSize(unsigned int optsize);
The value of the optimal size, in bytes.
This method closes the connection to the environment, and frees all related system resources.
void terminateConnection(Connection *connection);
A pointer to the connection instance to be terminated.
This method closes the connections in the connection pool, and frees all related system resources.
void terminateConnectionPool(ConnectionPool *poolp);
A pointer to the connection pool instance to be terminated.
This method closes the environment, and frees all related system resources.
void terminateEnvironment(Environment *env);
Environment to be closed.
|
Copyright © 2001, 2002 Oracle Corporation. All Rights Reserved. |
|