I have deployed my ear in JBOSS 7.1.1 AS. For viewing the document in application we are using the BFILE. Below code is used:
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();
}
We are using Ojdc6.11.2.0.3 jar.
In the manifest of ear I have dependencies org.jboss.ironjacamar.jdbcadapters
.
This works fine for JBOSS AS 7.1.1
But same ear doesnt work in JBOSS EAP 6.1 I get below exception
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.
I am baffled as almost all the things are same.