java.lang.ClassCastException:com.mchange.v2.c3p0.impl.NewProxyConnection [英] java.lang.ClassCastException: com.mchange.v2.c3p0.impl.NewProxyConnection
本文介绍了java.lang.ClassCastException:com.mchange.v2.c3p0.impl.NewProxyConnection的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我得到了以下
java.lang.ClassCastException: com.mchange.v2.c3p0.impl.NewProxyConnection
在执行以下代码时.您能帮我解决问题吗?
when the following code executes. could you please help me how to solve.
ComboPooledDataSource connPool = new ComboPooledDataSource();
connPool .setJdbcUrl(PropertyReader.getSystemProperty(DB_URL));
connPool .setUser(PropertyReader.getSystemProperty(DB_USER));
connPool .setPassword(Decryption.getDecryptedPwd(DB_PASSWORD));
connPool .setMaxPoolSize(MAX_POOL_SIZE);
connPool .setMaxIdleTime(MAX_IDLE_TIME);
connPool .setMinPoolSize(MIN_POOL_SIZE);
connPool .setMaxAdministrativeTaskTime(15);
java.sql.Connection conn = connPool.getConnection();
oracle.sql.CLOB c = CLOB.createTemporary(conn, false, CLOB.DURATION_SESSION);
Writer writer = c.setCharacterStream(0L);
writer.write(String.valueOf(pNoListDelimited).toCharArray());
writer.flush();
writer.close();
异常堆栈跟踪
java.lang.ClassCastException: com.mchange.v2.c3p0.impl.NewProxyConnection
at oracle.sql.CLOB.createTemporary(CLOB.java:676)
at oracle.sql.CLOB.createTemporary(CLOB.java:640)
……
…..
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
at java.util.concurrent.FutureTask.run(FutureTask.java:123)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:651)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:676)
at java.lang.Thread.run(Thread.java:595)
推荐答案
您正在使用Oracle特定的API,该API希望您的Connection是特定的Oracle Connection类.但是您正在使用的Connection是c3p0代理Connection,而不是Oracle Connection类.
you are using Oracle-specific API that expects your Connection to be a particular Oracle Connection class. But the Connection you are working with is a c3p0 proxy Connection, not that Oracle Connection class.
如果要使用特定于Oracle的api,则有几种选择:
if you want to use the Oracle-specific api, you have a few choices:
- 您可以使用c3p0的原始Connection操作,请参见 http://www.mchange .com/projects/c3p0/index.html#raw_connection_ops 作为您要查找的确切示例; 实际上,
- c3p0附带了一个用于执行此操作的Oracle jar文件.它很少使用,而且很老,所以有一点盐;
- 您可以升级到 c3p0-0.9.5的预发行版本 ,它支持完整的JDBC4 API,并使用unwrap操作提取原始Oracle Connection.
- you can use c3p0's raw Connection operations, see http://www.mchange.com/projects/c3p0/index.html#raw_connection_ops for the precise example you are looking for;
- c3p0 actually ships with a jar file for Oracle that performs this operation. it's rarely used and ages old, though, so a grain of salt;
- you can upgrade to a prerelease version of c3p0-0.9.5, which supports the full JDBC4 api, and use the unwrap operation to extract the raw Oracle Connection.
祝你好运!
这篇关于java.lang.ClassCastException:com.mchange.v2.c3p0.impl.NewProxyConnection的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文