使用Hibernate + Oracle 11g提取CLOB数据时出现java.sql.SQLRecoverableException

编程入门 行业动态 更新时间:2024-10-21 13:10:08
本文介绍了使用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

本文发布于:2023-07-22 23:47:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1192121.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据   Hibernate   Oracle   CLOB   SQLRecoverableException

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!