-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Using SessionFactory.close() method, Any Recomendations?
PostPosted: Sat Sep 13, 2008 9:00 am 
Newbie

Joined: Tue Sep 09, 2008 2:43 am
Posts: 1
Location: India
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0

I am using Hibernate 3.0 along with Oracle 10.2.0.3.0. my applicaiton is deployed on the JBoss 4.2.2 server.

The problem over here is that at the Oracle end, the database is bounced daily for backup activity. this results in all the connections gettign closed. Every morning when i cone back and try to log into my application, i get an error saying

"No more data to read from socket"

This i know occurs when you try to access a connection when it is closed. I get this erro when i try doing the following:

objSession = sessionFactory.openSession();
objCallableStmt = objSession.connection().prepareCall(strSPNAme);


As per my understanding, the Session Factory is able to create a Session, bu the Session is returning a closed connection from the Pool, closed because of the oracle maintanance. Someone please confirm this! :)

The hibernate properties in my hibernate.cfg.xml are as follows:


<session-factory>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@<server>:<port>:<instance></property>
<property name="connection.username"><user></property>
<property name="connection.password"><password></property>

<property name="connection.pool_size">40</property>

<property name="dbcp.defaultAutoCommit">false</property>
<property name="dbcp.maxActive">30</property>
<property name="dbcp.maxIdle">5</property>
<property name="dbcp.maxWait">1000</property>
<property name="dbcp.whenExhaustedAction">1</property>
<property name="dbcp.validationQuery">Select 1 from dual</property>
<property name="dbcp.timeBetweenEvictionRunsMillis">60000</property>
<property name="dbcp.numTestsPerEvictionRun">10</property>
<property name="dbcp.minEvictableIdleTimeMillis">90000</property>
<property name="dbcp.testWhileIdle">false</property>
<property name="dbcp.testOnBorrow">true</property>
<property name="dbcp.testOnReturn">true</property>
<property name="dbcp.ps.whenExhaustedAction">1</property>
<property name="dbcp.ps.maxActive">20</property>
<property name="dbcp.ps.maxWait">12000</property>
<property name="dbcp.ps.maxIdle">20</property>
<property name="dbcp.ps.validationQuery">Select 1 from dual</property>
<property name="dbcp.ps.timeBetweenEvictionRunsMillis">60000</property>
<property name="dbcp.ps.numTestsPerEvictionRun">10</property>
<property name="dbcp.ps.minEvictableIdleTimeMillis">90000</property>
<property name="dbcp.ps.testWhileIdle">false</property>
<property name="dbcp.ps.testOnBorrow">true</property>
<property name="dbcp.ps.testOnReturn">true</property>

<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>

<property name="current_session_context_class">thread</property>

<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

<property name="show_sql">true</property>
</session-factory>


I am using the dbcp transaction management and i have tried almost all options to resolve this issue, but nothing worked till now. Can anyone please suggest if this can be resolved by tuning the properties?

What i am thinking of doing now is checking if the connections in the pool are closed, and if they are closed, then closing the SessionFactory and rebuilding it. May be something like what is given below.


Session session = sessionFactory.openSession();
Connection conn = session.connection();
if (conn==null || conn.isClosed())
{
session.close();

sessionFactory.close();
sessionFactory = null;

sessionFactory = new Configuration().configure(
"/WEB-INF/hibernate.cfg.xml").buildSessionFactory();

}




can anyone please tell me what will happen to the Sessions and the Connections when i close the SessionFactory? Also, if i close the Session Factory, then will it leave any impact on the CPU Utiliztions or the memory utilizations?

In general, what could be the problems that arise from this procedure?

Please reply to teh post asap!!! Its urgent!!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.