【发布时间】:2021-05-12 18:47:32
【问题描述】:
我正在尝试从休眠中获取 oracle 连接。下面是我正在使用的代码。
server.xml
<library id="jdbcDriverFiles">
<fileset dir="libraries" includes="ojdbc7.jar" />
</library>
<dataSource id="x" jndiName="jndisce"
statementCacheSize="20" type="javax.sql.DataSource">
<containerAuthData password="Pwd" user="User" />
<jdbcDriver javax.sql.DataSource="oracle.jdbc.pool.OracleDataSource" libraryRef="jdbcDriverFiles" />
<connectionManager agedTimeout="600"
connectionTimeout="180" maxIdleTime="1800" maxPoolSize="70"
minPoolSize="1" purgePolicy="EntirePool" reapTime="180" />
<properties.oracle
URL="url"
password="Pwd" portNumber="123" serverName="server"
user="User" />
</dataSource>
<webApplication id="cm" location="cm.war"
name="cm">
<classloader commonLibraryRef="jdbcDriverFiles" />
</webApplication>
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("jndisce");
Connection conn = ds.getConnection();
OracleConnection con = conn.unwrap(OracleConnection.class);
以下是我遇到的错误。
java.sql.SQLException: DSRA9122E: com.ibm.ws.rsadapter.jdbc.v41.WSJdbc41Connection@7acaddcd does not
wrap any objects of type oracle.jdbc.OracleConnection.
【问题讨论】: