title: Apache Commons DBCP connection object problem, Thread: ClassCastException in org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper
body: <p>I am using Apache Commons DBCP (<code>commons-dbcp.jar</code>) Connection pool.</p>
  
  <p>Once I obtained a connection from the pool it is wrapped in the
  class <code>org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper</code>.</p>
  
  <p>My requirement is to pass an array of Strings to pl/sql stored procedure in Oracle.</p>
  
  <p>Here is what I am doing in the following code snippet:</p>
  
  <pre><code>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();
  </code></pre>
  
  <p>On executing the above code, I get the following exception:</p>
  
  <blockquote>
    <p>java.lang.ClassCastException: org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper cannot be cast to oracle.jdbc.OracleConnection
        at oracle.sql.ArrayDescriptor.createDescriptor</p>
  </blockquote>
  
  <p>I tried to find out solution over this going throughout almost of the sites and forums, but couldn't get the satisfied answer or solution on the same.</p>