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.
Pourquoi et quand exécuter cette tâche
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.
Procédure
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();
- Obtenir un objet oracle.jdbc.OraclePreparedStatement.
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();