User Authentication Using Cloudconnector
Page 5 of 6

Using a Connection from a Connection Pool

To use a connection from a connection pool in your client application:

  1. Create a java.util.Properties object.
  2. Set the weblogic.t3.connectionPoolID property to the name of the connection pool you created in the Tengah Server's weblogic.properties file.

The following simple example opens a connection to BEA WebLogic, sets up a Properties object, and then opens a series of connections from the "eng" connection pool created in a previous example.

Class.forName("COM.cloudscape.core.WebLogicDriver").newInstance();

// Set the weblogic.t3.connectionPoolID to specify
// the connection pool to use the connection from;
// specify userName and passwd for this connection.
//
Properties tengahProps = new Properties();
tengahProps.put("weblogic.t3.connectionPoolID", "eng");
tengahProps.put("user", "fred");
tengahProps.put("password", "fredPasswd");

Connection conn = DriverManager.getConnection(
    "jdbc:cloudscape:weblogic://localhost:7001"+
    "&weblogic.t3.cacheRows=0",
    tengahProps);

// Do some database work

// Release the connection
conn.close();

Note that the client releases the JDBC connection and returns it to the pool before disconnecting. When the JDBC connection is returned to the connection pool, all outstanding JDBC transactions are rolled back and closed.