参数值是CLOB类型,从表中取出CLOB转String报错
【操作无效:已关闭 Lob。 ERRORCODE=-4470, SQLSTATE=null】
解决方式:
1、jdbc URL链接为:jdbc.url=jdbc:db2://(ip):50000/(数据库名称):driverType=4;fullyMaterializeLobData=true;fullyMaterializeInputStreams=true;progressiveStreaming=2;progresssiveLocators=2;
2、db2命令窗口中使用命令:$ db2set DB2_RESTRICT_DDF=true,设置完后,重启数据库即可。

说明:
这个参数就是禁用渐进式流媒体的。
因为用渐进式流媒体的时候,其实真正的数据库的数据并没有存到对象,是指针定位器,所以移动光标或者结果集关闭的时候,就没法使用内容了,禁用后拿到的具体化的lob。
参考:
https://www.ibm.com/support/pages/disabling-progressive-streaming-clijdbc-applications
在这里插入图片描述
https://www.ibm.com/docs/en/db2/9.7?topic=sqlj-progressive-streaming-data-server-driver-jdbc
在这里插入图片描述
https://issues.redhat.com/browse/JBPAPP-2613?_sscc=t
在这里插入图片描述
在这里插入图片描述
https://stackoverflow.com/questions/22360721/com-ibm-db2-jcc-am-sqlexception-jcc10120119364-14-88-invalid-operation
问题:
In our application we are having a simple POJO class that has a Clob attribute within it.

I am having issue in getting the String representation of that Clob entity.

Say I have already queried and cached the result in the POJO object, now I am trying to get the String value of the Clob as below.

int aLength = (int)myPojo.getClobField().length();
String aStringValue = myPojo.getClobField().getSubString(1L, aLength);
But the above execution gives me the error,

com.ibm.db2.jcc.am.SqlException: [jcc][10120][11936][4.14.88] Invalid operation: Lob is closed. ERRORCODE=-4470, SQLSTATE=null

回答:
The Clob Java object is not a copy of the CLOB value stored in the database. It is a locator (pointer), which becomes invalid after the result set is closed. You’ll need to copy CLOB contents while processing the result set.

This issue can be solved by adding progressiveStreaming=2; argument to the connection url

The fully specified Connection URL is to be given as below:

jdbc:db2://localhost:50000/SAMPLE:progressiveStreaming=2;
In case you have exception on that parameter add the following to it or add any one or combinations of these parameters to fix it:
jdbc:db2://localhost:50000/SAMPLE:driverType=4;fullyMaterializeLobData=true;fullyMaterializeInputStreams=true;progressiveStreaming=2;progresssiveLocators=2;

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐