如何在jdbc中使用setClob方法? [英] How to use setClob method in jdbc?

查看:115
本文介绍了如何在jdbc中使用setClob方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将一个大字符串作为clob插入表中。我正在使用PreparedStatement的setClob方法。但是这些值没有插入到数据库表中。谁能告诉我如何使用setClob方法将字符串插入表中?

I need to insert a large string as clob into a table. I am using setClob method of PreparedStatement. But the values are not getting inserted into the database table. Can anyone tell me how I can insert the string into the table using setClob method?

我使用的方法如下:

pstmt.setClob(0,clob);

pstmt.setClob(0, clob);

但程序无法执行此行的语句。它从循环中出来并再次停在同一条线上等等......
如何使用Clob Object实现这一目标我处于两难境地。

But the program can't execute the statements from this line. It comes out of the loop and stops again at the same line and so on... I'm in a dilemma how to use Clob Object to achieve this.

请帮我解决这个问题。

提前致谢。

推荐答案

使用WebLogic和Oracle时遇到了同样的问题。
我在doc中找到了解决方案: http:/ /docs.oracle.com/cd/B19306_01/appdev.102/b14259/xdb11jav.htm 使用JDBC将大型XML文档加载到数据库部分下

I had the same problem using WebLogic and Oracle. I found the solution in the doc: http://docs.oracle.com/cd/B19306_01/appdev.102/b14259/xdb11jav.htm under the section "Loading a Large XML Document into the Database with JDBC"

我遇到的唯一问题是CLOB.createTemporary需要一个OracleConnection,但我的连接对象是$ ProxyXX类型,我无法在没有获得ClassCastException的情况下强制转换为OracleConnection。
解决了它使用conn.getMetaData()。getConnection()获得了一个T4CConnection我可以转换为OracleConnection。

The only problem I had with this was that the CLOB.createTemporary required an OracleConnection, but my connection object was of type $ProxyXX which I could not cast to OracleConnection without getting a ClassCastException. Solved it buy using conn.getMetaData().getConnection() that got me a T4CConnection which I could cast to OracleConnection.

这篇关于如何在jdbc中使用setClob方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆