Hello Sirs/friends I have a critical problem and struggling from last 15 days.My Go-live is on head.Please help me.
I am susing stuts,Hiberante3.0,SAP application server,Oracle database 9i. In Hibernate 3.0 i am using Session.openSession() method and closing using session.close().When i check in v$session afetr some time session is abbrupty increasing and not releasing.After some time database got hanged. I cant use session.getCurrentSession as it is available from 3.2.Now its risky to make it update from 3.0 to 3.2. PLEASE HELP ME.
Hibernate.cfg.file <property name="show_sql">true</property> <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property> <property name="hibernate.c3p0.acquire_increment">1</property> <property name="hibernate.c3p0.idle_test_period">100</property> <property name="hibernate.c3p0.max_size">15</property> <property name="hibernate.c3p0.min_size">3</property> <property name="hibernate.c3p0.timeout">300</property>
DAO Class: public List getEmployeeDetails(int employeeID) throws Exception { String employeeName = null; SessionFactory fact=null; Session session = null; System.out.println("Ist in DAO"); List empList=null; try{ fact = InitSessionFactory.getSessionFactory(); session = fact.openSession(); Criteria criteria = session.createCriteria(employee_POJO.class); System.out.println("Employee ID="+employeeID); criteria.add(Expression.eq("employeeNo",new Integer(employeeID))); empList = criteria.list(); System.out.println("Size="+empList.size()); for ( Iterator iter = empList.iterator(); iter.hasNext(); ) { employee_POJO employee_POJO = (employee_POJO) iter.next(); employeeName = employee_POJO.getEmployeeName(); String area=employee_POJO.getArea(); System.out.println("Queried EmployeeName for C3p="+employeeName); System.out.println("Queried area="+area); System.out.println("Queried Supervisor="+employee_POJO.getSupervisorID()); } // } catch(HibernateException err){ err.printStackTrace(); }finally{ session.flush(); session.close(); } return empList;
}
InitSessionFactory class: package com.claim.dao;
import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration;
import org.hibernate.*; import org.hibernate.cfg.*;
public class InitSessionFactory { private static SessionFactory sessionFactory;
static { try { // Create the SessionFactory from hibernate.cfg.xml System.out.println("entered the static try-catch block to read the configuration"); sessionFactory = new Configuration().configure("hibernate.cfg.xml").buildSessionFactory(); System.out.println("read the configuration file, created the session factory "+ sessionFactory); } catch (Throwable ex) { // Make sure you log the exception, as it might be swallowed System.out.println("Initial SessionFactory creation failed1=" + ex.getMessage()); System.out.println("Initial SessionFactory creation failed2=" + ex.getLocalizedMessage()); System.out.println("Initial SessionFactory creation failed3=" + ex.getCause()); throw new ExceptionInInitializerError(ex); } }
public static SessionFactory getSessionFactory() { return sessionFactory; }
} PLEASE HELP ME.I am waiting Thanks Soumitra
|