HomeDigital EditionSys-Con RadioSearch Java Cd
Advanced Java AWT Book Reviews/Excerpts Client Server Corba Editorials Embedded Java Enterprise Java IDE's Industry Watch Integration Interviews Java Applet Java & Databases Java & Web Services Java Fundamentals Java Native Interface Java Servlets Java Beans J2ME Libraries .NET Object Orientation Observations/IMHO Product Reviews Scalability & Performance Security Server Side Source Code Straight Talking Swing Threads Using Java with others Wireless XML

"Connecting the Java World to Grid-Enabled Databases"
Vol. 9, Issue 9, p. 32


Listing 1

// Example to show binding of OracleDataSource to JNDI
// with relevant cache properties set on the datasource.
import oracle.jdbc.pool.*; // import the pool package
Context ctx = new IntialContext(ht);
OracleDataSource ods = new OracleDataSource();

// Set Datasource properties
 ods.setURL("jdbc:oracle:thin:@(DESCRIPTION= (LOAD_BALANCE=on)

// Enable fast connection failover
ctx.bind("MyDS", ods);
ds = lookup("MyDS"); // lookup datasource from the cache

// implicitly create connection cache, that is set up for fast
// connection failover
conn = ds.getConnection();

// return connection to the cache

// close datasource and cleanup the cache

Listing 2

java.util.properties cacheProps = new Properties();
java.util.properties cacheWeights = null;

cacheWeights.setProperty("NLSLANG", "10");
cacheWeights.setProperty("SecurityGroup", "8");
cacheWeights.setProperty("Application", "4");
// set weights on the cache
cacheProps.put(CacheAttributeWeights, cacheWeights);

Listing 3

java.util.properties connAttr = null;
connAttr.setProperty("NLSLANG", "ISO-LATIN-1");
connAttr.setProperty("SecurityGroup", "1");
connAttr.setProperty("Application", "HR")

// Request connection

// First retrieval of connection from myCache
conn = ds.getConnection(connAttr);
// apply attributes on the connection
// Next retrieval finds the connection in the cache
conn = ds.getConnection(connAttr);

All Rights Reserved
Copyright ©  2004 SYS-CON Media, Inc.
  E-mail: [email protected]

Java and Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. SYS-CON Publications, Inc. is independent of Sun Microsystems, Inc.