当前位置: 代码迷 >> Java Web开发 >> ssh2中操作 clob类型报错 求解决方案,该如何处理
  详细解决方案

ssh2中操作 clob类型报错 求解决方案,该如何处理

热度:6650   发布时间:2013-02-25 21:20:16.0
ssh2中操作 clob类型报错 求解决方案
sql脚本字段如下 
SQL code
create table contentinfo(    contentdetail clob not null,  );


hibernate 映射文件如下
XML code
<property name="contentdetail" type="text">  <column name="CONTENTDETAIL" not-null="true"/></property>


现在执行添加/修改 文本内容少的话 正常执行操作
文本内容多大话 出现异常 求高手解决。。。。小弟在此非常感谢。。



错误信息如下
org.springframework.jdbc.UncategorizedSQLException: Hibernate flushing: could not insert: [com.bsth.pdyg.domain.Contentinfo]; uncategorized SQLException for SQL [insert into PDYG.CONTENTINFO (TITLE, USER_NAME, PUBDATE, CONTENTDETAIL, CONTENT_TYPE, CID) values (?, ?, ?, ?, ?, ?)]; SQL state [null]; error code [17090]; 不允许的操作: streams type cannot be used in batching; nested exception is java.sql.SQLException: 不允许的操作: streams type cannot be used in batching

java.sql.SQLException: 不允许的操作: streams type cannot be used in batching



------解决方案--------------------------------------------------------
把batch_size设置为0
------解决方案--------------------------------------------------------
把batch_size设置为0
------解决方案--------------------------------------------------------
恩,正好项目里用到,给你贴贴代码,给点思路给你,我是这样实现的
1.在hbm.xml 文件修改,将<property name="contentdetail" type="text"> <column name="CONTENTDETAIL" not-null="true"/> </property> 的type 改为type="java.sql.Clob"
2.对应的实体类的属性contentdetail 的 类型为 java.sql.Clob
3.重点哦!!!这个也是看到一位高手这样解决的
1)clob类型的数据不能直接insert,要先通过empty_clob()方法给它分配一个locator(同理,blob的用empty_blob()函数分配locator).然后把它select出来(此时它当然没有数据,但结果集不是空的),得到一个Clob的对象,修改该对象的内容让它满足我们的需要,再通过update方法更新该行记录.
2) 通过select修改含lob类型的记录时一定要锁定该行(通过for update关键字实现),否则oracle会报错. 3) 刚插入的记录就select for update, 会出现"违反读取顺序"错误,解决办法是将自动提交功能置为false,即不允许自动提交,然后commit它,再select,就可以了!
------解决方案--------------------------------------------------------
哦,具体你可以看看高手的博客http://blog.csdn.net/gaowenming/article/details/4964767 

------解决方案--------------------------------------------------------
真没碰到过,学习了。
------解决方案--------------------------------------------------------
探讨
把batch_size设置为0

------解决方案--------------------------------------------------------
探讨

哦,具体你可以看看高手的博客http://blog.csdn.net/gaowenming/article/details/4964767
  相关解决方案