Troubleshooting
Problem
New in JDBC 4.0: The wrapper pattern now allows JDBC programmers to access vendor-specific JDBC APIs safely in an application server managed environment. Previous to JDBC 4.0, the WebSphere Application Server proprietary WSCallHelper interface had to be used to accomplish the same task.
Symptom
If the wrapper pattern is not followed and a vendor-specific JDBC API is invoked directly, the following type of error will be logged:
[12/12/11 12:34:39:911 EDT] 00000059 SystemErr R Caused by: java.sql.SQLFeatureNotSupportedException: DSRA1300E: Feature is not implemented: PreparedStatement.setClob
[12/12/11 12:34:39:912 EDT] 00000059 SystemErr R at com.ibm.ws.rsadapter.AdapterUtil.notSupportedX(AdapterUtil.java:1306)
[12/12/11 12:34:39:912 EDT] 00000059 SystemErr R at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.setClob(WSJdbcPreparedStatement.java:1875)
[12/12/11 12:34:39:912 EDT] 00000059 SystemErr R at com.citigroup.solar.pnlview.dao.impl.ExportPnLViewDAO.putInUploadQueue(ExportPnLViewDAO.java:782)
[12/12/11 12:34:39:912 EDT] 00000059 SystemErr R ... 59 more
[12/12/11 12:34:39:913 EDT] 00000059 SystemErr R Caused by: java.lang.AbstractMethodError: java/sql/PreparedStatement.setClob(ILjava/io/Reader;)V
[12/12/11 12:34:39:913 EDT] 00000059 SystemErr R at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.setClob(WSJdbcPreparedStatement.java:1859)
[12/12/11 12:34:39:913 EDT] 00000059 SystemErr R ... 60 more
Cause
In the above example, the .setClob() method is an Oracle-specific method which is not part of standard JDBC 4.0.
Environment
Requirements to use the JDBC 4.0 wrapper pattern:
- WebSphere Application Server v7.0 or higher. Refer to this Information Center page for more information:
Specifications and API documentation
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=matt&product=was-nd-dist&topic=rovr_specs - JDBC 4.0-compliant JDBC driver.
Consult with your driver vendor to determine the JDBC spec level.
Resolving The Problem
The following code snippets show how the JDBC 4.0 wrapper pattern can be used to obtain a native Oracle connection or a native Oracle PreparedStatement object:
1. Obtain an oracle.jdbc.OracleConnection:
Context ic = new InitialContext();
DataSource ds = (DataSource)ic.lookup("jdbc/OracleDS");
Connection conn = ds.getConnection();
// Returns true if this either implements the interface argument
// or is directly or indirectly a wrapper for an object that does.
if (conn.isWrapperFor(oracle.jdbc.OracleConnection.class)) {
// Returns an object that implements the given interface to
// allow access to non-standard methods, or standard methods
// not exposed by the proxy.
oracle.jdbc.OracleConnection oraCon = conn.unwrap(oracle.jdbc.OracleConnection.class);
// Do some Oracle-specific work here.
}
conn.close();
2. Obtain an 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 Oracle-specific work here.
}
pstmt.close();
conn.close();
Was this topic helpful?
Document Information
Modified date:
15 June 2018
UID
swg21577331