SSH C3PO Oracle Stored Procedure pass Array

Source: Internet
Author: User
Tags oracleconnection

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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.