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

编程技术  /  houtizong 发布于 3年前   90
今天看到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版本中,则必须配置才可以正常创建连接池。

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

请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!

留言需要登陆哦

技术博客集 - 网站简介:
前后端技术:
后端基于Hyperf2.1框架开发,前端使用Bootstrap可视化布局系统生成

网站主要作用:
1.编程技术分享及讨论交流,内置聊天系统;
2.测试交流框架问题,比如:Hyperf、Laravel、TP、beego;
3.本站数据是基于大数据采集等爬虫技术为基础助力分享知识,如有侵权请发邮件到站长邮箱,站长会尽快处理;
4.站长邮箱:[email protected];

      订阅博客周刊 去订阅

文章归档

文章标签

友情链接

Auther ·HouTiZong
侯体宗的博客
© 2020 zongscan.com
版权所有ICP证 : 粤ICP备20027696号
PHP交流群 也可以扫右边的二维码
侯体宗的博客