A java.lang.ClassCastException Occurs When an OracleCallableStatement Is Used with the Universal Connection Pool (UCP) (Doc ID 759103.1)

Last updated on AUGUST 16, 2016

Applies to:

JDBC - Version 10.2.0 to 11.1.0.6
Information in this document applies to any platform.

Symptoms

A simple application that uses the Universal Connection Pool (UCP) and an OracleCallableStatement to call a simple PL/SQL procedure fails with a java.lang.ClassCastException.

The simple PL/SQL procedure is:

create or replace procedure NoTypesDoNothing is
begin
    null;
end;
/

The java application is:

import java.sql.*;
import oracle.ucp.jdbc.PoolDataSourceFactory;
import oracle.ucp.jdbc.PoolDataSource;
import oracle.jdbc.driver.OracleCallableStatement;

public class NoTypesX
{
  public static void main (String[] args) 
  {
    try 
    {    
      PoolDataSource pds = PoolDataSourceFactory.getPoolDataSource();
      pds.setConnectionFactoryClassName("oracle.jdbc.pool.OracleDataSource");
      pds.setURL("jdbc:oracle:thin:@bkell1.ca.oracle.com:1521:ORCL1");
      pds.setUser("scott");
      pds.setPassword("tiger");
      Connection conn = pds.getConnection(); 

      String query = "{call NoTypesDoNothing}";
      OracleCallableStatement ocs = (OracleCallableStatement)conn.prepareCall(query);
      
      conn.close();
      conn=null;
    }
    catch (Exception e) 
    {
      e.printStackTrace(); 
    }
  }
}


The test resulting in the exception is:

D:\TestJdbc>set PATH=C:\Program Files\Java\jdk1.5.0_17\bin

D:\TestJdbc>set CLASSPATH=.;d:\JdbcDrivers\10.2.0.4\lib\ojdbc14.jar;d:\UCP\ucp.jar

D:\TestJdbc>javac NoTypesX.java

D:\TestJdbc>java NoTypesX
java.lang.ClassCastException: oracle.jdbc.driver.$Proxy1
        at NoTypesX.main(NoTypesX.java:20)

D:\TestJdbc>


Sometimes it can happen that following error is reported instead:

java.lang.ClassCastException: oracle_jdbc_driver_T4CCallableStatement_Proxy

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms