本文介绍了连接池与Spring&过冬的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用Spring和Hibernate配置连接池?
How to configure connection pooling with Spring and Hibernate?
谢谢
Venu
推荐答案
您可以使用DBCP组件
You can use DBCP component
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="initialSize" value="10" />
<property name="maxActive" value="5" />
<property name="maxWait" value="5000" />
</bean>
<!-- Hibernate Configuration -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
p:dataSource-ref="dataSource">
<property name="annotatedClasses">
<list>
<value>com.project.domain.Domain1</value>
<value>com.project.domain.Domain1</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
${hibernate.dialect}
</prop>
<prop key="hibernate.show_sql">
${hibernate.show_sql}
</prop>
<prop key="hibernate.generate_statistics">
${hibernate.show_statistics}
</prop>
</props>
</property>
</bean>
这篇关于连接池与Spring&过冬的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!