日期:2014-05-17  浏览次数:20808 次

求救!关于hibernateTemplate连接数的问题
DAO

public class PayDAO {

private ApplicationContext bf=new ClassPathXmlApplicationContext("applicationContext.xml");
private HibernateTemplate hibernateTemplate=(HibernateTemplate)bf.getBean("hibernateTemplate");

public List<Company> getCompanys(){
String queryString="from Company";
List<Company> list=hibernateTemplate.find(queryString);
return list;
}
}

配制文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"
       default-lazy-init="false">
       
   <!-- Activates scanning of @Autowired -->
   <context:annotation-config/>

   <!-- Activates scanning of @Repository and @Service -->
   <context:component-scan base-package="com.contract"/>



   <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="ignoreUnresolvablePlaceholders" value="true"/>
        <property name="locations">
            <list>
                <value>classpath:jdbc.properties</value>               
            </list>
        </property>
    </bean>
     <!-- DataSource -->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="${jdbc.driverClassName}"/>
        <property name="url" value="${jdbc.url}"/>