10.12.2012 Views

Oracle C++ Call Interface Programmer's Guide

Oracle C++ Call Interface Programmer's Guide

Oracle C++ Call Interface Programmer's Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

const string poolUserName = "SCOTT";<br />

const string poolPassword = "TIGER";<br />

const string connectString = "";<br />

const string username = "SCOTT";<br />

const string password = "TIGER";<br />

unsigned int maxConn = 5;<br />

unsigned int minConn = 3;<br />

unsigned int incrConn = 2;<br />

Connecting to a Database<br />

ConnectionPool *connPool = env->createConnectionPool(poolUserName, poolPassword,<br />

connectString, minConn, maxConn, incrConn);<br />

See Also:<br />

■ Appendix A, "OCCI Demonstration Programs" and the code<br />

example occipool.cpp that demonstrates how to use the<br />

connection pool interface of OCCI<br />

You can also configure all these attributes dynamically. This lets you design an<br />

application that has the flexibility of reading the current load (number of open<br />

connections and number of busy connections) and tune these attributes<br />

appropriately. In addition, you can use the setTimeOut method to time out the<br />

connections that are idle for more than the specified time. The DBMS terminates<br />

idle connections periodically so as to maintain an optimum number of open<br />

connections.<br />

Each connection pool has a data structure (pool handle) associated with it. This pool<br />

handle stores the pool parameters. There is no restriction that one environment<br />

must have only one connection pool. There can be multiple connection pools in a<br />

single OCCI environment, and these can connect to the same or different databases.<br />

This is useful for applications requiring load balancing. However, note that since a<br />

pool handle requires memory, multiple connection pools consume more memory.<br />

Proxy Connections<br />

If you authorize the connection pool user to act as a proxy for other connections,<br />

then no password is required to log in database users who use one of the<br />

connections in the connection pool to act as a proxy on their behalf.<br />

A proxy connection can be created by using either of the following methods:<br />

ConnectionPool->createProxyConnection(const string &name,<br />

Connection::ProxyType proxyType =<br />

Connection::PROXY_DEFAULT);<br />

Relational Programming 2-5

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!