Migrating applications that use the WSCallHelper interface to Liberty
WebSphere® Application Server traditional provides the now-deprecated
WSCallHelper
interface. Applications that use the associated proprietary APIs can
be updated to use the standard Java™ Database Connectivity
(JDBC) wrapper pattern.
About this task
In WebSphere Application Server traditional, applications use the
WSCallHelper
interface to access nonstandard 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
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
nonstandard 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();