Oracle GlassFish Server 3.0.1 Application Development Guide

Obtaining a Physical Connection From a Wrapped Connection

The DataSource implementation in the GlassFish Server provides a getConnection method that retrieves the JDBC driver’s SQLConnection from the GlassFish 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); //get physical connection from wrapper
// Do db operations.
// Do not close driver connection.
con.close(); // return wrapped connection to pool.