Database Reference
In-Depth Information
OCI connection pool connections recognize the terminal name and can return the Domain name
along with the OS user name.
Here is the catch. An OCI connection pool is very slow to be set up , the connections are heavyweight
and demand more resources. Once set up, and using existing connections in the pool, performance is
not an issue. For this reason, an OCI connection pool is suitable for server-based applications with a
long runtime duration (e.g., within a web application server).
Proxy Sessions from a Thin Client Connection Pool
While connection pools are generally only needed for Server applications supporting multiple,
concurrent users, you might have some call for a multi-threaded, stand-alone or client application that
will perhaps need to reuse multiple connections from a pool—be creative! A thin-client connection pool
or cache is a great way to accomplish this. Our approach to single sign-on can succeed within it.
Configuring the Pool/Cache
We establish the lightweight (thin) connection pool through an oracle.jdbc.pool.OracleDataSource
class. Set the URL (connection string), user, and password that all connections in the pool will have.
They will all connect as appusr .
Edit the connection string (URL), appusrConnURL , setting the appropriate host, port, and instance;
and set the correct password for appusr in appusrConnPassword . The URL is specified in TNSNames
format. Notice in Listing 8-15 that the URL specifies a thin (light-weight) connection as
“jdbc:oracle:thin”. Thin connections require fewer resources and are set up faster than OCI connections.
Thin connections use only java to communicate by SQL*Net protocol with Oracle Database, as opposed
to using OCI as an external, non-java resource to run SQL*Net. We name our connection cache (pool),
“APP_CACHE.”
Listing 8-15. Configure Thin-Client Connection Pool
private String appusrConnThinURL =
"jdbc:oracle: thin :@(description=(address=(host=" +
"127.0.0.1)(protocol=tcp)(port=1521))(connect_data=" +
"(INSTANCE_NAME=orcl)(SERVICE_NAME=orcl.org.com)))";
OracleDataSource cpool = new OracleDataSource();
cpool.setURL(appusrConnThinURL);
cpool.setUser(appusrConnUser);
cpool.setPassword(appusrConnPassword);
// Enable Connection Caching
cpool.setConnectionCachingEnabled(true);
cpool.setConnectionCacheName(" APP_CACHE ");
Properties prop = new Properties();
prop.setProperty("InitialLimit", "3");
prop.setProperty("MinLimit", "2");
prop.setProperty("MaxLimit", "10");
cpool. setConnectionCacheProperties (prop);
 
Search WWH ::




Custom Search