Sun Java System Application Server Platform Edition 8.1 2005Q2 Update 2 Developer's Guide

- Previous: Sharing Connections
- Next: Using Non-Transactional Connections

## 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.DataSource ds = (com.sun.appserv.DataSource)
       ctx.lookup("jdbc/MyBase");
    Connection con = ds.getConnection();
    Connection drivercon = ds.getConnection(con);
    // Do db operations.
    con.close();

- Previous: Sharing Connections
- Next: Using Non-Transactional Connections

- © 2010, Oracle Corporation and/or its affiliates