I get the `DSRA9122E: com.ibm.ws.rsadapter.jdbc.WS

2019-08-29 04:20发布

Am using Websphere 18 Liberty Version. When am trying to unwrap java.sql.connection to oracle.jdbc.OracleConnection I get the

`DSRA9122E: com.ibm.ws.rsadapter.jdbc.WSJdbcConnection@d3t7e556 does not wrap any objects of type oracle.jdbc.OracleConnection

In sever.xml file am using ojdbc7.jar for datasource, also in application I added same jar from the same location. Still am facing the issue. I referred all links WSJDBCConnection does not wrap objects of type oracle.jdbc.OracleConnection like this. Still am facing the same issue.

2条回答
Luminary・发光体
2楼-- · 2019-08-29 04:38

You don't need to unwrap to OracleConnection. You can use Connection object to establish the connection to the DB.

// Get a context for the JNDI look up
DataSource ds = getDataSource();
try (Connection connection = ds.getConnection()) {
  {
   executeBusinessLogicOnDatabase(connection));
   ......
  }
  connection.close();
  }
查看更多
时光不老,我们不散
3楼-- · 2019-08-29 04:58

In order for Connection.unwrap to work properly, the Liberty DataSource and the Application must both load the vendor implementation class (oracle.jdbc.OracleConnection) from the same class loader.

Here is a simple example of how to configure both the dataSource and your application to use the same class loader to load from a single library that contains the Oracle JDBC driver,

<library id="OracleLib">
    <fileset dir="${server.config.dir}/oracle"/>
</library>

<application location="myApp.war" >
    <classloader commonLibraryRef="OracleLib"/>
</application>

<dataSource jndiName="jdbc/oracleDataSource">
    <jdbcDriver libraryRef="OracleLib"/>
    <properties.oracle .../>
</dataSource>
查看更多
登录 后发表回答