Sun Java System Application Server Enterprise Edition 8.2 Developer's Guide

Obtaining a Physical Connection from a Wrapped Connection

The DataSource implementation in the Application Server provides a getConnection method that retrieves the JDBC driver’s SQLConnection from the Application Server’s Connection wrapper. The method signature is as follows:

public java.sql.Connection getConnection(java.sql.Connection con) 
throws java.sql.SQLException

For example:

InitialContext ctx = new InitialContext();
com.sun.appserv.jdbc.DataSource ds = (com.sun.appserv.jdbc.DataSource) 
Connection con = ds.getConnection();
Connection drivercon = ds.getConnection(con);
// Do db operations.

If you get a Connection from an Application Server JDBC connection pool, create a Statement object, and then use the Statement.getConnection method, the statement returns the physical connection instead of the wrapped connection. When you close this physical connection, you break the connection pool logic. To avoid this problem, use the following asadmin create-jvm-options command, then restart the server:

asadmin create-jvm-options -Dcom.sun.appserv.jdbc.wrapJdbcObjects=true

For more information about the asadmin create-jvm-options command, see the Sun Java System Application Server Enterprise Edition 8.2 Reference Manual.