我正在使用hibernate3和springframework。
我想为hibernate.connection.provider_class设置c3P0池,但显然设置了 LocalDataSourceConnectionProvider 。
在Hibernate.log中我看到了:
[级别:INFO]初始化连接提供程序: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider
我认为 org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider 是用于池化的hibernate默认连接提供程序类,因为我读到它在生产中使用是错误的。这是对的吗?
我想设置 org.hibernate.connection.C3P0ConnectionProvider 并使用c3p0管理池连接
这是我的hibernate配置:
<bean id="c3p0Datasource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass">
<value>oracle.jdbc.driver.OracleDriver</value>
</property>
<property name="jdbcUrl">
<value>.......</value>
</property>
<property name="user">
<value>.......</value>
</property>
<property name="password">
<value>.......</value>
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="c3p0Datasource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.default_schema">.....</prop>
<prop key="hibernate.hbm2ddl.auto">UPDATE</prop>
<prop key="hibernate.cache.use_second_level_cache">false</prop>
<prop key="hibernate.cache.use_query_cache">false</prop>
<prop key="cache.provider_class">org.hibernate.cache.NoCacheProvider</prop>
<prop key="hibernate.connection.zeroDateTimeBehavior">convertToNull</prop>
<prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.connection.isolation">2</prop>
</props>
</property>
</bean>
有什么建议吗?