Java code calls the stored procedure and uses multiple database connection methods when passing in array parameters. Here I use:
C3p0 connection pool, spring 2.5, Hibernate 3.2.3
But this exception always exists,
Java. Lang. classcastexception: COM. mchange. v2.c3p0. impl. newproxyconnection cannot be cast to Oracle. JDBC. oracleconnection
At com. becom. Reports. Service. Ext. impl. rptsrvrolemanagerext. saverolefunc (rptsrvrolemanagerext. Java: 241)
At sun. Reflect. nativemethodaccessorimpl. invoke0 (native method)
At sun. Reflect. nativemethodaccessorimpl. Invoke (nativemethodaccessorimpl. Java: 39)
At sun. Reflect. delegatingmethodaccessorimpl. Invoke (delegatingmethodaccessorimpl. Java: 25)
At java. Lang. Reflect. method. Invoke (method. Java: 597)
At org. springframework. AOP. Support. aoputils. invokejoinpointusingreflection (aoputils. Java: 281)
At org. springframework. AOP. Framework. reflectivemethodinvocation. invokejoinpoint (reflectivemethodinvocation. Java: 187)
At org. springframework. AOP. Framework. reflectivemethodinvocation. Proceed (reflectivemethodinvocation. Java: 154)
At org. springframework. transaction. Interceptor. transactioninterceptor. Invoke (transactioninterceptor. Java: 107)
At org. springframework. AOP. Framework. reflectivemethodinvocation. Proceed (reflectivemethodinvocation. Java: 176)
At org. springframework. AOP. Framework. jdkdynamicaopproxy. Invoke (jdkdynamicaopproxy. Java: 210)
At $ proxy13.saverolefunc (unknown source)
At com. becom. Reports. webapp. Action. rolefunc. roleaction. dosaverights (roleaction. Java: 213)
At sun. Reflect. nativemethodaccessorimpl. invoke0 (native method)
Database: Oracle 10g r2
Because the method for retrieving connections is the proxy Implementation of the original JDBC connection, but fails when the proxy implementation is converted to the JDBC connection, it only takes one sentence to modify this exception,
Need to add package
Spring-1.2-rc1.jar
Add it to the Java file.
Import
Org. springframework. JDBC. Support. nativejdbc. c3p0nativejdbcextractor;
Finally, set the following connection method
Oracleconnection connection = (oracleconnection)
Preparedstatement. getconnection ();
Replace:
C3p0nativejdbcextractor cp30nativejdbcextractor = new c3p0nativejdbcextractor ();
Oracleconnection connection = (oracleconnection) cp30nativejdbcextractor. getnativeconnection (preparedstatement. getconnection ());
It's easy to get rid of the problem KO. Haha, some problems and solutions encountered during development will be shared. I hope the developers will not take any detours!