title: java.sql.SQLRecoverableException while fetching CLOB data using Hibernate + oracle 11g
body: <p>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.</p>
  
  <p>Below is my source where I am getting an Exception :</p>
  
  <pre><code>java.sql.Clob reqClob= userBean.getRequestData();
  Reader clbReader = reqClob.getCharacterStream();
  </code></pre>
  
  <p>In above Code while executing "clob.getCharacterStream()", I am getting below Exception :</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>Please note that, I am able to get the data from userBean for other values.</p>
  
  <p>Below is the app version I have used in application:</p>
  
  <pre><code>jdk1.6.0_33 (64bit version)  
  hibernate3.jar 
  ojdbc6.jar 
  Oracle 11g 11.2.0.1.0 - (64bit version)
  </code></pre>
  
  <p>One strange behavior is I am getting this issue once I have started using TOMCAT 7 Datasource.</p>
  
  <p>Below is Datasource code from Context.xml :</p>
  
  <pre><code>&lt;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" /&gt;
  </code></pre>
  
  <p>I have tried all possible parameters for in above code, but it didn't work.</p>
  
  <p>Thanks in advance for all your help, guys...</p>