Apache Commons DBCP connection object problem, Thread: ClassCastException in org.apache.tomcat.dbcp.dbcp.poolingDataSource$PoolGuardConnectionWrapper
我正在使用Apache Commons DBCP () Connection pool。commons-dbcp.jar
一旦我从池中获得连接,它就会被包装在类中。org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper
我的要求是将字符串数组传递给Oracle中的pl / sql存储过程。
以下是我在以下代码段中执行的操作:
Connection dbConn = ConnectionManager.ds.getConnection();
//The above statement returns me an connection wrapped in the class
//org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.
org.apache.commons.dbcp.DelegatingConnection del = new org.apache.commons.dbcp.DelegatingConnection(dbConn.getConnection());
con = del.getInnermostDelegate();
cs = con.prepareCall("call SP_NAME(?,?,?,?)");
oracle.sql.ArrayDescriptor arDesc= oracle.sql.ArrayDescriptor.createDescriptor("ARRAY_NAME", (OracleConnection) con);
CallableStatement c_stmt = conn.prepareCall("begin update_message_ids_ota
(:x); end;" );
c_stmt.setArray( 1, array_to_pass );
c_stmt.execute();
在执行上述代码时,我得到以下异常:
java.lang.ClassCastException: org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper can not cast to oracle.jdbc.OracleConnection at oracle.sql.ArrayDescriptor.createDescriptor
我试图在几乎整个网站和论坛中找到解决方案,但无法得到满意的答案或解决方案。