我正在尝试将C3P0实现到我的hibernate中。我有如下:
hibernate.cfg.xml中
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://IPaddress</property>
<property name="hibernate.connection.username">user</property>
<property name="hibernate.connection.password">password</property>
<property name="hibernate.current_session_context_class">thread</property>
<!-- JDBC connection pool (use the built-in) -->
<!--<property name="connection.pool_size">20</property>-->
<property name="hibernate.c3p0.acquire_increment">1</property>
<property name="hibernate.c3p0.idle_test_period">1000</property>
<property name="hibernate.c3p0.max_size">10</property>
<property name="hibernate.c3p0.max_statements">10</property>
<property name="hibernate.c3p0.min_size">10</property>
<property name="hibernate.c3p0.timeout">864000</property>
<property name="hibernate.c3p0.idleConnectionTestPeriod">30</property>
<property name="hibernate.c3p0.initialPoolSize">10</property>
<property name="hibernate.c3p0.maxPoolSize">100</property>
<property name="hibernate.c3p0.minPoolSize">10</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Mappings -->
<mapping class="com.nebuilder.ats.pojo.TopicsDetails"/>
<mapping class="com.nebuilder.ats.pojo.GroupsDetails"/>
<mapping class="com.nebuilder.ats.pojo.ModulesDetails"/>
<mapping class="com.nebuilder.ats.pojo.TraineesDetails"/>
<mapping class="com.nebuilder.ats.pojo.ColoursDetails"/>
<mapping class="com.nebuilder.ats.pojo.CustomersDetails"/>
<mapping class="com.nebuilder.ats.dao.MusicStoreDaoImpl"/>
</session-factory>
</hibernate-configuration>
的applicationContext.xml
<beans>
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
p:location="classpath:jdbc.properties"/>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="${jdbc.driverClassName}"
p:url="${jdbc.url}"
p:username="${jdbc.username}"
p:password="${jdbc.password}"
p:connectionProperties="${jdbc.connectionProperties}"/>
<!-- ADD PERSISTENCE SUPPORT HERE (jpa, hibernate, etc) -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>
<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
</beans>
这两个文件都在我的资源文件夹中。它们似乎正在工作,但问题是当我尝试访问数据库时,我的页面不加载或刷新而不显示任何信息。
我正在使用jars如下 - hibernate-c3p0 3.6.3.Final,hibernate-core 3.6.3.Final,c3p0 0.9.1.2
答案 0 :(得分:0)
您是否尝试调试应用程序以查看问题所在? 而且,定义864 000 ms的超时似乎有点过分,不是吗?