-->
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: Hibernate - C3P0 connection pool - leak
PostPosted: Thu Sep 22, 2011 2:26 pm 
Newbie

Joined: Thu Sep 22, 2011 1:50 pm
Posts: 1
Hibernate - C3P0 connection pool - leak

Hi

We are accessing Hibernate C3P0 connection pool using the following hibernate.cfg.xml. The idea is to ensure that there are no more than one active
connection to database. If there are two thread accessing connection from pool, the second thread should be waiting for first to complete
and release connection from pool. However we see multiple connections to DB - like more than 2 connection . Wondering if there is some setting that we
missed out here? Can someone please help us here.


<hibernate-configuration>
<session-factory name="">
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.password">333</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@(DESCRIPTION
= (ADDRESS = (PROTOCOL = TCP)(HOST = xx.us.xx.com)(PORT
= 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = xx.us.xx.com)) (LOAD_BALANCE = yes) (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=yy.dev.amer.xx.com)))</property>
<property name="hibernate.connection.username">xx</property>
<property name="hibernate.default_schema">SDR</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="hibernate.connection.autoReconnect">true</property>
<property name="hibernate.c3p0.idle_test_period">60</property>
<property name="hibernate.c3p0.min_size">0</property>
<property name="hibernate.c3p0.max_size">1</property>
<property name="hibernate.c3p0.timeout">30</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.connection.release_mode">after_statement</property>
<property name="show_sql">true</property>
<mapping resource="com/xx/AssetData.hbm.xml"/>
</session-factory>
</hibernate-configuration>

Accessing hibernate frameowrk - using the following JAVA code.


HashMap returnObject = new HashMap();
Query query = null;
Session session = null;
String beanClassName1 = "com.xx.bean.AssetData";
CacheLoadUtility cCacheLoadUtility = new CacheLoadUtility();
cCacheLoadUtility.setBeanClassName(beanClassName1);
int start = 0;
try {
session = cCacheLoadUtility.callConfig();
//System.out.println("session=" + session);
String qQueryStatment = null;
AssetData aAssetData = null;
query = cCacheLoadUtility.loadSimpleQueryStatement(session, keyName, identifierMap);
query.setFirstResult(0);
query.setMaxResults(recordCount);
List listOfResultSet = query.list();
// System.out.println("list of query is "+ listOfResultSet.size());
// returnObject = listOfResultSet;
if (listOfResultSet.size() != 0) {
Object objInner = null;
Object key = null;
AssetHeaderData aAssetHeaderData = null;
EntitlementSummaryData eEntitlementSummaryData = null;
for (Object resultBean : listOfResultSet) {
aAssetData = (AssetData) resultBean;
objInner = aAssetData.getId();
key = objInner;
aAssetHeaderData = buildAssetHeaderData(aAssetData);
eEntitlementSummaryData = buildEntitlementSummaryData(aAssetData);
ArrayList aList = new ArrayList();
//int hashCode = aAssetHeaderData.hashCode();
Object obj = returnObject.get(aAssetHeaderData);

if(returnObject.get(aAssetHeaderData)!=null)
{
aList = (ArrayList) returnObject.get(aAssetHeaderData);
}
aList.add(eEntitlementSummaryData);
returnObject.put(aAssetHeaderData, aList);
}
// Remove Last AssetHeaderData.
if(listOfResultSet.size() >= recordCount)
returnObject.remove(aAssetHeaderData);
session.clear();
session.flush();
}

} catch (Throwable e) {
log("com.dell.it.services.sdr.blazeload.util.CacheLoadUtility.load "
+ "Object is not loaded properly.. - " + e,
CacheFactory.LOG_ERR);
CacheFactory.log(e);
} finally
{
if (session != null)
session.close();
}

Thanks
sunder


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.