Migrating applications that use the WSCallHelper interface to Liberty

The WSCallHelper interface, which is used in WebSphere® Application Server traditional, must be migrated to the Java™ Database Connectivity (JDBC) wrapper pattern for the application to work in Liberty. The WSCallHelper APIs, which were deprecated in WebSphere Application Server 7.0, are not available in WebSphere Application Server Liberty.

About this task

In WebSphere Application Server traditional, applications use the WSCallHelper interface to access non-standard vendor-specific JDBC APIs. For Liberty, use the JDBC wrapper pattern, which is a more standard JDBC specification-based approach. The wrapper pattern enables JDBC programmers to implement the Wrapper interface to access vendor-specific JDBC APIs safely in an application server managed environment. For the wrapper pattern to work, the JDBC driver must be compliant with the JDBC 4.0 or later specification level. To determine the JDBC specification level, consult your driver vendor.

Procedure

Implement the Wrapper interface isWrapperFor and unwrap methods to access vendor-specific JDBC APIs.

The following examples demonstrate how you can use the JDBC wrapper pattern to obtain a native Oracle connection or a native Oracle PreparedStatement object to call the non-standard vendor-specific methods.

  • Obtain an oracle.jdbc.OracleConnection object.
    Context ic = new InitialContext();
    DataSource ds = (DataSource)ic.lookup("jdbc/OracleDS");
    Connection conn = ds.getConnection();
    
    if (conn.isWrapperFor(oracle.jdbc.OracleConnection.class)) {
        oracle.jdbc.OracleConnection oraCon = conn.unwrap(oracle.jdbc.OracleConnection.class);
        // Do some vendor-specific work here.
    }
    conn.close();
  • Obtain an oracle.jdbc.OraclePreparedStatement object.
    Context ic = new InitialContext();
    DataSource ds = (DataSource)ic.lookup("jdbc/OracleDS");
    Connection conn = ds.getConnection();
    
    PreparedStatement pstmt = conn.prepareStatement("SELECT 1 FROM DUAL");
    if(pstmt.isWrapperFor(oracle.jdbc.OraclePreparedStatement.class)){
        oracle.jdbc.OraclePreparedStatement opstmt = pstmt.unwrap(oracle.jdbc.OraclePreparedStatement.class);
        // Do some vendor-specific work here.
    }
    pstmt.close();
    conn.close();

Icon that indicates the type of topic Task topic



Timestamp icon Last updated: Monday, 5 December 2016
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=twlp_mig_wscallhelper
File name: twlp_mig_wscallhelper.html