我正在尝试使用JDBC将CLOB数据发送到存储的proc中。我正在使用Oracle数据库11g和ojdbc6.jar作为驱动程序。我无法发送数据,因为它大于32kb。我尝试了多种发送数据的方法:


使用Clob对象
使用characterStream


这些都不对我有用。
我收到以下错误:
ORA-22828:输入模式或替换参数超过32K大小限制

是否有某种方法可以使用jdbc(java)将大数据传递到oracle存储的proc中,它可以扩展到1MB。
使用的代码如下:

CallableStatement cstmt = null;

String formedStr = "{CALL MAIL_PROC(?)}";
//Preparing statement
cstmt = con.prepareCall(formedStr);
cstmt.setCharacterStream(1, new StringReader(info.getContent()), info.getContent().length());
cstmt.execute();

最佳答案

我作为Clob传入的String对象存在问题。它包含下一行(\ r \ n)。当我删除它时,通话进展顺利。
我使用了三种类型的调用来传递Clob对象,并且现在都可以正常工作:

CallableStatement cstmt = null;

String formedStr = "{CALL MAIL_PROC(?)}";

cstmt = con.prepareCall(formedStr);

//Option 1:
cstmt.setCharacterStream(1, new StringReader(info.getContent()), info.getContent().length());

//Option 2:
cstmt.setString(1, info.getContent());

//Option 3:
Clob stmtClob = con.createClob();
stmtClon.setString(1,info.getContent())
cstmt.setClob(1,stmtClob);

cstmt.execute();

09-05 00:00
查看更多