connection pooling is not working and also tomcat is getting stuck after some time of usage.
application context file is
---------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"><value>org.postgresql.Driver</value></property>
<property name="url"><value>jdbc:postgresql://localhost:5433/SOPA_CS</value>
</property><property name="username"><value>client111111111</value></property>
<property name="password"><value>client111111111</value></property>
<property name="initialSize"><value>1</value></property>
<property name="maxActive"><value>1000</value></property>
<property name="maxIdle"><value>10</value></property>
<property name="removeAbandoned"><value>true</value></property>
<property name="removeAbandonedTimeout"><value>60</value></property>
<property name="logAbandoned"><value>true</value></property>
<property name="maxWait"><value>60000</value></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="dataSource" />
</property>
<property name="mappingDirectoryLocations">
<list>
<value>classpath:/com/getset/inventory/model</value>
<value>classpath:/com/getset/inventory/returns/model</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.PostgreSQLDialect
</prop>
<!-- Disable the second-level cache -->
<prop key="cache.provider_class">
org.hibernate.cache.NoCacheProvider
</prop>
<!-- Echo all executed SQL to stdout -->
<prop key="show_sql">true</prop>
<!-- Drop and re-create the database schema on startup -->
<!-- <prop key="hbm2ddl.auto">create</prop> -->
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
<property name="cacheQueries">
<value>true</value>
</property>
</bean>
<bean id="hibernateDaoSupport"
class="org.springframework.orm.hibernate3.support.HibernateDaoSupport"
abstract="true">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
<!-- You could use the configured Hibernate template or create
a new mapping that uses a configured hibernate template.
HibernateDaoSupport creates a HibernateTempalte with the default settings.
NOTE THIS IS COMMENTED OUT.-->
<property name="hibernateTemplate">
<ref bean="hibernateTemplate"/>
</property>
</bean>
<!-- JDBC TEMPLATES -->
<bean id="jdbcTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="txProxyTemplate" abstract="true"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager" ref="jdbcTransactionManager"/>
<property name="transactionAttributes">
<props>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="mark*">PROPAGATION_REQUIRED</prop>
<prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource">
<ref bean="dataSource"/>
</property>
</bean>
<!--<bean id="userDaoImplJdbc" class="com.getset.inventory.dao.setup.impl.UserDaoImplJdbc">
<property name="dataSource" ref="dataSource"/>
</bean>-->
<!-- end JDBC TEMPLATES -->
<bean id="LocalDAO" class="com.getset.inventory.dao.LocalDAO">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="accountHeadsDaoImpl" class="com.getset.inventory.dao.setup.impl.AccountHeadsDaoImpl">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="CategoryDaoImpl" class="com.getset.inventory.dao.setup.impl.CategoryDaoImpl">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
</beans>
-------------------------------------------------------------
manager class has a method with the following code: this methodis getting hitted from DWR/ AJAX
------------------
DBFunctions objDbFunctions=new DBFunctions();
CategoryDaoImpl categoryDaoImpl = (CategoryDaoImpl)objDbFunctions.getDaoImplBean(SpringBeanConstants.CATEGORY_DAO_IMPL,WebContextFactory.get().getServletContext());
List<Category> categoryList=new ArrayList<Category>();
try{
categoryList=categoryDaoImpl.loadCategories();
}catch(Exception ex){
LoggerHelper.logException(this.getClass().getName(), "", "Exception Occurred "+ex);
}
--------------------------
DAO impl class has the method
public List<Category> loadCategories() {
LoggerHelper.initialize();
LoggerHelper.logInfo(this.getClass().getName(), "loadByID", "entering the method");
List<Category> allCategories=null;
try{
getHibernateTemplate().flush();
allCategories =getHibernateTemplate().find("from Category order by categoryName");
}catch(Exception e){
LoggerHelper.logException(this.getClass().getName(), "loadByID", "exception occured" + e);
}
LoggerHelper.logInfo(this.getClass().getName(), "loadByID", "ending the method");
return allCategories;
}
---------------------------------------------------------
utility class has this method to retunr the daoimpl class from context which is injected thru spring
public Object getDaoImplBean(String strBeanName, ServletContext context) {
LoggerHelper.initialize();
// getting the spring application context from the servlet context
ApplicationContext applContext = WebApplicationContextUtils.getWebApplicationContext(context);
//getting basic datasource bean to monitor the connections
BasicDataSource basicDs = (BasicDataSource) applContext.getBean("dataSource");
LoggerHelper.logInfo(this.getClass().getName(), "getDaoImplBean", "Number of idle connections: " + basicDs.getNumIdle());
LoggerHelper.logInfo(this.getClass().getName(), "getDaoImplBean", "Number of active connections: " + basicDs.getNumActive());
System.out.println("Number of idle connections===getDaoImplBean===: " + basicDs.getNumIdle());
System.out.println("Number of active connections===getDaoImplBean===: " + basicDs.getNumActive());
// getting the bean object from the spring application context
return applContext.getBean(strBeanName);
}
------------------------
this is teh code flow thru out teh application. when we print the active connections its getting increased on each screen/click ..
|