Oracle® C++ Call Interface Programmer's Guide 10g Release 1 (10.1) Part Number B10778-01 |
|
|
View PDF |
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.
Table 10-14 Constants of the Environment Class
Constant | Description |
---|---|
DEFAULT |
The default mode for creating an Environment object; no thread safety or object support |
OBJECT |
Mode for creating an Environment object; uses object features. |
SHARED |
Shared mode for creating an Environment object. |
NO_USERCALLBACKS |
Mode for creating an Environment object; does not support user callbacks. |
THREADED_MUTEXED |
Thread safe mode for creating an Environment object, mutexed internally by OCCI |
THREADED_UNMUTEXED |
Thread safe mode for creating an Environment object, client is responsible for mutexing. |
EVENTS |
Mode for creating an Environment object; supports registration for event notification (Advanced Queuing). |
USE_LDAP |
Mode for creating an Environment object; supports registration with LDAP. |
Table 10-15 Summary of Environment Methods
Method | Summary |
---|---|
createConnection() |
Establish a connection to the specified database. |
createConnectionPool() | Create a connection pool. |
createEnvironment() | Create an Environment object. |
createStatelessConnectionPool() | Create a stateless connection pool. |
enableSubscription() |
Enables subscription notification |
disableSubscription() |
Disables subscription notification |
getCacheMaxSize() |
Retrieve the Cache Max heap size. |
getCacheOptSize() |
Retrieve the cache optimal heap size. |
getCacheSortedFlush() |
Retrieve the setting of the cache sorting flag. |
getCurrentHeapSize() |
Return the current amount of memory allocated to all objects in the current environment. |
getEnvironment() |
Returns the Environment used for creating a Subscription . |
getLDAPAdminContext() |
Returns the administrative context when using LDAP open notification registration. |
getLDAPAuthentication() |
Returns the authentication mode when using LDAP open notification registration. |
getLDAPHost() |
Returns the host on which the LDAP server runs. |
getLDAPPort() |
Returns the port on which the LDAP server is listening. |
getMap()() | Return the Map for the current environment. |
getOCIEnvironment() |
Return the OCI environment associated with the current environment. |
getXAConnection() |
Create an XA connection to a database. |
getXAEnvironment() |
Create an XA Environment object. |
releaseXAConnection() |
Release all resources allocated by a getXAConnection() call. |
releaseXAEnvironment() |
Release all resources allocated by a getXAEnvironment() call. |
setCacheMaxSize() |
Specifies the maximum size for the client-side object cache as a percentage of the optimal size. |
setCacheOptSize() |
Specifies the optimal size for the client-side object cache in bytes. |
setCacheSortedFlush() |
Speechifies whether to sort cache in table order prior to flushing. |
setLDAPAdminContext() |
Speechifies the administrative context for the LDAP client. |
setLDAPAuthentication() |
Speechifies the LDAP authentication mode. |
setLDAPHostAndPort() |
Speechifies the LDAP server host and port. |
setLDAPLoginNameAndPassword() |
Speechifies the login name and password when connecting to an LDAP server. |
terminateConnection() |
Close the connection pool and free all related resources. |
terminateConnectionPool() |
Close the connection pool and free all related resources. |
terminateEnvironment() |
Destroy the environment. |
terminateStatelessConnectionPool() |
Close the stateless connection pool and free all related resources. |
This method establishes a connection to the database specified.
Syntax | Description |
---|---|
Connection * createConnection( const string &username, const string &password, const string &connectString); |
Creates a default connection. |
Connection * createConnection( const UString &username, const UString &password, const UString &connectString); |
Creates a connection (Unicode support). The client Environment should be initialized in OCCIUTIF16 mode. |
Parameter | Description |
---|---|
username |
The name of the user with which to connect. |
password |
The password of the user. |
connectString |
The database to which the connection is made. |
Create a connection pool based on the parameters specified.
Syntax | Description |
---|---|
ConnectionPool* createConnectionPool( const string &poolUserName, const string &poolPassword, const string &connectString = "", unsigned int minConn = 0, unsigned int maxConn = 1, unsigned int incrConn = 1); |
Creates a default connection pool. |
ConnectionPool* createConnectionPool( const UString &poolUserName, const UString &poolPassword, const UString &connectString, unsigned int minConn = 0, unsigned int maxConn = 1, unsigned int incrConn = 1); |
Creates a connection pool (Unicode support). The client Environment should be initialized in OCCIUTIF16 mode. |
Parameter | Description |
---|---|
poolUserName |
The pool user name. |
poolPassword |
The pool password. |
connectString |
The connection string for the server |
minConn |
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. |
maxConn |
The maximum number of connections in the pool. Valid values are 1 and greater. |
incrConn |
The increment by which to increase the number of connections to be opened if the current number of connections is less than maxConn . Valid values are 1 and greater. |
Create 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_UNMUTEXED
, then all three memory management functions must be thread-safe.
Syntax | Description |
---|---|
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); |
Creates a default environment. |
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, const std::string &charset, const std::string &ncharset); |
Creates an environment with the specified character set and NCHAR character set ids (Unicode support). The client Environment should be initialized in OCCIUTIF16 mode. |
Parameter | Description |
---|---|
mode |
Valid values are (see Table 10-14 for descriptions) DEFAULT , THREADED_MUTEXED , THREADED_UNMUTEXED , OBJECT . |
ctxp |
Context pointer for user-defined memory management function. |
size |
The size of the memory to be allocated by user-defined memory allocation function. |
newsize |
The new size of the memory to be reallocated. |
memptr |
the existing memory that needs to be reallocated to new size. |
malocfp |
User-defined memory allocation function. |
ralocfp |
User-defined memory reallocation function. |
mfreefp |
User-defined memory free function. |
charset |
Character set id that will replace the one specified in NLS_LANG . |
ncharset |
Character set id that will replace the one specified in NLS_NCHAR . |
Create a StatelessConnectionPool
object with specified pool attributes.
StatelessConnectionPool* createStatelessConnectionPool( const string &poolUserName, const string &poolPassword, const string connectString="", unsigned int maxConn=1, unsigned int minConn=0, unsigned int incrConn=1, enum StatelessConnectionPool::Mode=StatelessConnectionPool::HETEROGENEOUS);
Parameter | Description |
---|---|
poolUserName |
The pool user name. |
poolPassword |
The pool password. |
connectString |
The connection string for the server |
maxConn |
The maximum number of connections that can be opened in the pool; additional sessions cannot be open. |
minConn |
The number of connections initially created in a pool. This parameter is considered only if the mode is set to HOMOGENEOUS . |
incrConn |
The number of connections by which to increment the pool if all open connections are busy, up to a maximum open connections specified by maxConn parameter. This parameter is considered only if the mode is set to HOMOGENEOUS . |
Mode |
The mode of the connection pool, which can be either HIOMOGENEOUS or HETEROGENEOUS .
|
Enables subscription notification.
void enableSubscription( Subscription &subscr);
Parameter | Description |
---|---|
subscr |
The Subscription. |
Disables subscription notification.
void disableSubscription( Subscription &subscr);
Parameter | Description |
---|---|
subscr |
The Subscription. |
Retrieves the Cache Max heap size.
unsigned int getCacheMaxSize() const;
Retrieves the Cache optimal heap size.
unsigned int getCacheOptSize() const;
Retrieves the current setting of the cache sorting flag; TRUE
or FALSE
.
bool getCacheSortedFlush();
Returns the amount of memory currently allocated to all objects in this environment.
unsigned int getCurrentHeapSize() const;
Returns the Environment
used for creating a Subscription
.
Environment* getEnvironment() const;
Returns the administrative context when using LDAP open notification registration.
string getLDAPAdminContext() const;
Returns the authentication mode when using LDAP open notification registration.
unsigned int getLDAPAuthentication() const;
Returns the host on which the LDAP server runs.
string getLDAPHost() const;
Returns the port on which the LDAP server is listening.
string unsigned intgetLDAPPort() const;
Returns a pointer to the map for this environment.
Map *getMap() const;
Returns a pointer to the OCI environment associated with this environment.
LNOCIEnv *getOCIEnvironment() const;
Returns a pointer to an OCCI Connection object that corresponds to the one opened by the XA library.
get XAConnection( const string &dbname);
Parameter | Description |
---|---|
dbname |
The database name; same as the optional dbname provided in the Open String (and used in connection to the Resource Manager). |
Returns a pointer to an OCCI Environment object that corresponds to the one opened by the XA library.
getXAEnvironment( const string &dbname);
Parameter | Description |
---|---|
dbname |
The database name; same as the optional dbname provided in the Open String (and used in connection to the Resource Manager). |
Release/deallocate all resources allocated by the getXAConnection() method.
releaseXAConnection( Connection* conn);
Parameter | Description |
---|---|
conn |
The connection returned by the getXAConnection() method. |
Release/deallocate all resources allocated by the getXAEnvironment() method.
releaseXAEnvironment( Environment* env);
Parameter | Description |
---|---|
env |
The environment returned by the getXAEnvironment() 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);
Parameter | Description |
---|---|
maxSize |
The value of the maximum size, as a percentage. |
Sets the optimal size for the client-side object cache in bytes. The default value is 8MB.
void setCacheOptSize( unsigned int optSize);
Parameter | Description |
---|---|
optSize |
The value of the optimal size, in bytes. |
Sets the cache flushing protocol. By default, objects in cache are flushed in the order they are modified; flag=FALSE
. To improve server-side performance, set flag=TRUE
, so that the objects in cache are sorted in table order prior to flushing from client cache.
void setCacheSortedFlush( bool flag);
Parameter | Description |
---|---|
flag |
FALSE (default) -- no sorting; TRUE -- sorting in table order |
Sets the administrative context of the client. This is usually the root of the Oracle RDBMS LDAP schema in the LDAP server.
void setLDAPAdminContext( const string &ctx);
Parameter | Description |
---|---|
ctx |
The client context |
Specifies the authentication mode. Currently the only supported value is 0x1: Simple authentication; username/password authentication.
void setLDAPAuthentication( unsigned int mode);
Parameter | Description |
---|---|
mode |
The authentication mode |
Specifies the host on which the LDAP server is running, and the port on which it is listening for requests.
void setLDAPHostAndPort( const string &host, unsigned int port);
Parameter | Description |
---|---|
host |
The host for LDAP |
port |
The port for LDAP |
Specifies the login distinguished name and password used when connecting to an LDAP server.
void setLDAPLoginNameAndPassword( const string &login, const &passwd);
Parameter | Description |
---|---|
login |
The login name |
passwd |
The login password |
Closes the connection to the environment, and frees all related system resources.
void terminateConnection( Connection *connection);
Parameter | Description |
---|---|
connection |
A pointer to the connection instance to be terminated. |
Closes the connections in the connection pool, and frees all related system resources.
void terminateConnectionPool( ConnectionPool *poolPointer);
Parameter | Description |
---|---|
poolPointer |
A pointer to the connection pool instance to be terminated. |
Closes the environment, and frees all related system resources.
void terminateEnvironment( Environment *env);
Parameter | Description |
---|---|
env |
Environment to be closed. |
Destroy the specified Stateless Connection Pool.
void termimnateStatelessConnectionPool( StatelessConnectionPool* scp, StatelessConnectionPool::DestroyMode mode=StatelessConnectionPool::DEFAULT);
Parameter | Description |
---|---|
scp |
The Stateless ConnectionPool to be destroyed. |
mode | Valid values are:
|
Warning: When the pool is terminated using the |