欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

今天升级hibernate3.2GA遇到一个很奇怪的问题(谢谢大家,已解决) HibernateMySQLCacheSpringOpenSource 

程序员文章站 2022-05-29 22:57:10
...
今天看到hibernate3.2ga版出来,赶紧更新。

我原来用的是hibernate3.1.3版本+Spring2.0,结果更新后,我配置的c3p0连接池是死活也连接不上了。

数据库是mysql,它在那里一直"Building new Hibernate SessionFactory".

一口气创建了好多。输出信息是这样的:

....-Building new Hibernate SessionFactory
....-Building new Hibernate SessionFactory
....-Building new Hibernate SessionFactory
....-Building new Hibernate SessionFactory
....-Building new Hibernate SessionFactory

然后报错:

WARN  com.mchange.v2.resourcepool.BasicResourcePool - com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@16528a2 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30).
2006-10-18 02:07:03,125 [main] WARN  org.hibernate.cfg.SettingsFactory - Could not obtain connection metadata
java.sql.SQLException: Connections could not be acquired from the underlying database!


把jar包换成hibernate3.1.3.jar就完全正常,用hibernate3.2GA的包就出上面的错误。


我的配置如下:

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="mappingResources">
<list>
<value>/domain/Admin.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<!--connection-->
<prop key="hibernate.connection.driver_class">${hibernate.connection.driver_class}</prop>
<prop key="hibernate.connection.url">${hibernate.connection.url}</prop>
<prop key="hibernate.connection.username">${hibernate.connection.username}</prop>
<prop key="hibernate.connection.password">${hibernate.connection.password}</prop>
<prop key="hibernate.useUnicode">${hibernate.useUnicode}</prop>
<prop key="hibernate.characterEncoding">${hibernate.characterEncoding}</prop>
<prop key="hibernate.autoReconnect">${hibernate.autoReconnect}</prop>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.default-lazy-init">${hibernate.default-lazy-init}</prop>
<prop key="hibernate.connection.provider_class">${hibernate.connection.provider_class}</prop>
<!--Connection Pooling-->
<prop key="hibernate.c3p0.max_size">${hibernate.c3p0.max_size}</prop>
<prop key="hibernate.c3p0.min_size">${hibernate.c3p0.min_size}</prop>
<prop key="hibernate.c3p0.timeout">${hibernate.c3p0.timeout}</prop>
<prop key="hibernate.c3p0.max_statements">${hibernate.c3p0.max_statements}</prop>
<prop key="hibernate.c3p0.idle_test_period">${hibernate.c3p0.idle_test_period}</prop>
<prop key="hibernate.c3p0.acquire_increment">${hibernate.c3p0.acquire_increment}</prop>
<prop key="hibernate.c3p0.validate">${hibernate.c3p0.validate}</prop>
</props>
</property>
</bean>



实在是不明白这两个版本的hibernate为什么会造成这种情况,不知道大家有没有出现过这种情况,怎么解决这个问题呢???




问题已解决,谢谢大家!

产生的问题是因为没有配置hibernate.cache.provider_class,很奇怪的问题,在3.1.3版本中缓存提供类并非必须的。而在3.2版本中,则必须配置才可以正常创建连接池。

:) 万分感谢楼下各位的热心!!