我已经在 JBOSS 7.1.1 AS 中部署了我的耳朵。为了在应用程序中查看文档,我们使用 BFILE。使用以下代码:
Connection con = this.jdbcTemplate.getDataSource().getConnection();
con = unwrapConnection(con);
if(null != con)
{
System.out.println("Is conncetion Closed" + con.isClosed());
PreparedStatement ps = con.prepareStatement(sql);
ResultSet rs = ps.executeQuery();
while(rs.next()) {
{
OracleResultSet ors = rs.unwrap(OracleResultSet.class);
bfile = ors.getBFILE(1);
fileName = rs.getString(2);
docFormat = rs.getString(3);
}
bfileMap.put("EventDocDetails", bfile);
bfileMap.put("Format", docFormat);
bfileMap.put("FileName", fileName);
}
private static Connection unwrapConnection(Connection connection) throws SQLException {
System.out
.println("Datasource is maintained by Jboss so Unwarping Jboss JDBC Connection to oracle.jdbc.OracleConnection. Driver name is "
+ connection.getMetaData().getDriverName());
return (oracle.jdbc.OracleConnection) ((WrappedConnection) connection)
.getUnderlyingConnection();
}
我们使用的是 Ojdc6.11.2.0.3 jar。在 ear 的清单中,我有 dependencies org.jboss.ironjacamar.jdbcadapters
。
这适用于 JBOSS AS 7.1.1
但是同样的耳朵在 JBOSS EAP 6.1 中不起作用我得到以下异常
oracle.jdbc.driver.T4CConnection cannot be cast to oracle.jdbc.OracleConnection
19:54:51,395 ERROR [stderr] (http-/192.168.178.31:8080-5) java.lang.ClassCastException: oracle.jdbc.driver.T4CConnection cannot be cast to oracle.jdbc.OracleConnection.
我很困惑,因为几乎所有的事情都是一样的。