我有一个Spring和Hibernate的项目,但它们使用了很多连接到我的数据库(MYSQL)。我知道我应该实现一个C3P0来管理池连接,但是我不知道如何实现。请帮我个忙。
Hibernate的配置:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost/oasis"/>
<property name="username" value="root"/>
<property name="password" value="mysql"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="packagesToScan">
<list>
<value>com.app.oasis.model.base</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<tx:annotation-driven/>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>我必须在哪里添加C3P0配置?
发布于 2011-06-28 15:06:51
将maven jar文件(从c3p0 website下载或使用C3P0 )添加到类路径中,并使用com.mchange.v2.c3p0.ComboPooledDataSource创建dataSource
<bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="com.mysql.jdbc.Driver"/>
<property name="jdbcUrl" value="jdbc:mysql://localhost/oasis"/>
<property name="user" value="root"/>
<property name="password" value="mysql"/>
<!-- Various configuration properties can be set here -->
</bean>https://stackoverflow.com/questions/6501268
复制相似问题