使用Hibernate + Oracle 11g提取CLOB数据时出现java.sql.SQLRecoverableException [英] java.sql.SQLRecoverableException while fetching CLOB data using Hibernate + oracle 11g

查看:396
本文介绍了使用Hibernate + Oracle 11g提取CLOB数据时出现java.sql.SQLRecoverableException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当在Java Web应用程序中使用Hibernate从Oracle 11g中获取CLOB数据时,出现了 java.sql.SQLRecoverableException:Closed Connection异常。对于数据库连接,我已经实现了Tomcat 7 dataource。

I am getting "java.sql.SQLRecoverableException: Closed Connection", exception while fetching CLOB data from Oracle 11g using Hibernate in java web application. For DB connectivity I have implemented Tomcat 7 dataource.

下面是我遇到异常的来源:

Below is my source where I am getting an Exception :

java.sql.Clob reqClob= userBean.getRequestData();
Reader clbReader = reqClob.getCharacterStream();

在上面的代码中,执行 clob.getCharacterStream()时,出现以下异常:

In above Code while executing "clob.getCharacterStream()", I am getting below Exception :

java.sql.SQLRecoverableException: Closed Connection
at oracle.sql.CLOB.getDBAccess(CLOB.java:1389)
at oracle.sql.CLOB.getCharacterStream(CLOB.java:309)
at org.hibernate.lob.SerializableClob.getCharacterStream(SerializableClob.java:41)

请注意,我能够从userBean获取其他值的数据。

Please note that, I am able to get the data from userBean for other values.

以下是我在应用程序中使用的应用程序版本:

Below is the app version I have used in application:

jdk1.6.0_33 (64bit version)  
hibernate3.jar 
ojdbc6.jar 
Oracle 11g 11.2.0.1.0 - (64bit version)

一个奇怪的行为是,一旦我开始使用TOMCAT 7数据源,就会遇到这个问题。

One strange behavior is I am getting this issue once I have started using TOMCAT 7 Datasource.

下面是来自Context.xml的数据源代码:

Below is Datasource code from Context.xml :

<Resource auth="Container" driverClassName="oracle.jdbc.driver.OracleDriver" 
factory="oracle.jdbc.pool.OracleDataSourceFactory" name="jdbc/XXXX" password="XXXXX" 
type="oracle.jdbc.pool.OracleDataSource" 
url="jdbc:oracle:thin:@xx.xx.xx.xxxx:xxxx:xxxxxx" user="username"
connectionProperties="SetBigStringTryClob=true;" maxActive="20"
maxIdle="10" maxWait="-1" validationQuery="select 1 from dual" />

我在上面的代码中尝试了所有可能的参数,但是没有用。

I have tried all possible parameters for in above code, but it didn't work.

在此先感谢大家的帮助,

Thanks in advance for all your help, guys...

推荐答案

I今天遇到同样的问题,并且总是在我调用 getSubString getCharacterStream 时出现关闭连接错误。

I had the same problem today and always when i was calling getSubString or getCharacterStream i had the Closed Connection error.

我用注解解决了并删除Clob类型:

I solved with annotation and removed the Clob type:

@Column(name = "CL_JSON_OUT", nullable = false)
private Clob jsonOut;

至:

@Lob
@Column(name = "CL_JSON_OUT", nullable = false)
private String jsonOut;

此帖子帮助了我

这篇关于使用Hibernate + Oracle 11g提取CLOB数据时出现java.sql.SQLRecoverableException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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