错误保存并从数据库SQL oracle中获取blob [英] Error Saving and getting blob from database SQL oracle

查看:217
本文介绍了错误保存并从数据库SQL oracle中获取blob的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 我试图将一个CLOB保存到数据库中并恢复它,但是我得到一个SQLException:由于:java.sql.SQLException:另一个读/写正在进行时调用的Lob读/写函数:getBytes()$ b $ at oracle.jdbc.driver.T4CConnection.getBytes(T4CConnection.java:2427)
at oracle.sql.BLOB.getBytes(BLOB.java:348)
at oracle.jdbc.driver.OracleBlobInputStream.needBytes(OracleBlobInputStream.java:181)

我认为问题出在我试图获得CLOB时,因为它仍然保存着。
如果CLOB很小,它可以正常工作,但是当CLOB稍大一点时就会失败。



对不起,我的英语和感谢



编辑:

注解是:

  @Lob 
@Column(nullable = false)
private String body;

保存方法

  emailRepository.save(电子邮件); 


解决方案

设置hibernate属性

 < property name =hibernate.temp.use_jdbc_metadata_defaultsvalue =false/> 

为我解决了这个问题。



将SessionFactory的lobCreator设置为NonContextualLobCreator可能是更好的解决方案(尚未尝试过)。



然而,我不确定是什么原因导致了此错误。


I'm trying to save a CLOB into the database and recovering it, but I'm getting an SQLException:

Caused by: java.sql.SQLException: Lob read/write functions called while another read/write is in progress: getBytes()
 at oracle.jdbc.driver.T4CConnection.getBytes(T4CConnection.java:2427)
 at oracle.sql.BLOB.getBytes(BLOB.java:348)
 at oracle.jdbc.driver.OracleBlobInputStream.needBytes(OracleBlobInputStream.java:181)

I figured that the problem is when I tried to get the CLOB, because it's still saving. If the CLOB is small it works fine, but when the CLOB is a little bigger it fails.

Sorry about my english and thanks

EDIT:

The annotation is:

@Lob
@Column(nullable = false)
private String body;

The save method

emailRepository.save(email); 

解决方案

Setting the hibernate property

<property name="hibernate.temp.use_jdbc_metadata_defaults" value="false"/>

sorved the problem for me.

Setting the lobCreator for SessionFactory to NonContextualLobCreator is probably a better solution (not tried yet).

However I'm not sure what causes this error.

这篇关于错误保存并从数据库SQL oracle中获取blob的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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