现有代码抛出此错误[Hibernate + c3p0 + Oracle11g]:一个资源池无法从其主工厂或源获取资源 [英] Existing code throws this error [Hibernate + c3p0 + Oracle11g]: a resourcepool could not acquire a resource from its primary factory or source

查看:409
本文介绍了现有代码抛出此错误[Hibernate + c3p0 + Oracle11g]:一个资源池无法从其主工厂或源获取资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我试图连接到一个测试数据库时,根据显示的设置,我面临着上述所有错误。

大部分配置都来自正常的生产环境,但我无法连接到我的测试数据库。



我已经尝试了各种方法,它只是无法正常运行。



我能够通过连接测试数据库其他方法如PLSQL开发人员或SQLPLUS。



我收到的错误包括:

  org .hibernate.exception.GenericJDBCException:无法打开连接
....
....
....
导致:java.sql.SQLException:连接无法从底层数据库中获取!
....
....
....
由com.mchange.v2.resourcepool.CannotAcquireResourceException引起:ResourcePool无法从其中获取资源主要工厂或来源。
at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.j ava:1422)
at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResour cePool.java:606)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool .java:526)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutAndMarkConnectionInUse(C3P0PooledConnectionPool.java:756) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0P ooledConnectionPool.java:683)



<这是我的hibernate配置文件:

 < session-factory> 

< property name =hibernate.connection.url> jdbc:oracle:thin:@ipaddress:1521:dbname< / property>
< property name =hibernate.connection.driver_class> oracle.jdbc.driver.OracleDriver< / property>
< property name =hibernate.connection.username>用户< / property>
< property name =hibernate.connection.password>密码< / property>



< property name =connection.autoReconnect> true< / property>
< property name =connection.autoReconnectForPools> true< / property>
< property name =connection.is-connection-validation-required> true< / property>

< property name =hibernate.connection.provider_class> org.hibernate.connection.C3P0ConnectionProvider< / property>
< property name =hibernate.c3p0.max_size> 1< / property>
< property name =hibernate.c3p0.min_size> 1< / property>
< property name =hibernate.c3p0.timeout> 50000< / property>
< property name =hibernate.c3p0.max_statements> 100< / property>
< property name =hibernate.c3p0.idle_test_period> 3000< / property>
< property name =hibernate.c3p0.acquire_increment> 1< / property>
< property name =hibernate.c3p0.validate> false< / property>


< property name =dialect> org.hibernate.dialect.Oracle10gDialect< / property>
< property name =hibernate.show_sql> true< / property>
< property name =hibernate.transaction.factory_class> org.hibernate.transaction.JDBCTransactionFactory< / property>

<映射资源等>
< / session-factory>

任何人都可以帮我解决这个问题吗?

解决方案

发生这种情况的原因很多,例如

您输入的数据库配置详细信息不正确或已更改,例如您的Confluence数据库的数据库名称或数据库用户名/密码。



1)数据库的URL不正确。



2)数据库服务器没有运行。如果您的数据库服务器已关闭,请重新启动它并检查日志,以查看它为什么失败或停止。



3)网络已关闭(或者有防火墙在汇合和干扰数据库服务器之间),并且无法建立到数据库的连接。



4)您的数据库密码已过期。



5)检查您的驱动程序是否存在你的班级路径。


when i am trying to connect to a test db which settings as per shown, i am faced all the errors as per mentioned.

most of the config is taken from working production environment but i am not able to connect to my test db.

i have tried various methods and it just fails to run properly.

Im able to connect test db via other methods such as PLSQL developer or SQLPLUS.

The errors i am getting in a bunch are :

org.hibernate.exception.GenericJDBCException: Cannot open connection
....
....
....
Caused by: java.sql.SQLException: Connections could not be acquired from the underlying database!
....
....
....
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
  at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.j‌​ava:1422)
  at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResour‌​cePool.java:606) 
  at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool‌​.java:526)
  at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutAndMarkConnectionInUse‌​(C3P0PooledConnectionPool.java:756) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0P‌​ooledConnectionPool.java:683)

this is my config file for hibernate :

<session-factory>

    <property name="hibernate.connection.url">jdbc:oracle:thin:@ipaddress:1521:dbname</property>
    <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
    <property name="hibernate.connection.username">user</property>
    <property name="hibernate.connection.password">password</property>



    <property name="connection.autoReconnect">true</property>
    <property name="connection.autoReconnectForPools">true</property>
    <property name="connection.is-connection-validation-required">true</property>

    <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
    <property name="hibernate.c3p0.max_size">1</property>
    <property name="hibernate.c3p0.min_size">1</property>
    <property name="hibernate.c3p0.timeout">50000</property>
    <property name="hibernate.c3p0.max_statements">100</property>
    <property name="hibernate.c3p0.idle_test_period">3000</property>
    <property name="hibernate.c3p0.acquire_increment">1</property>
    <property name="hibernate.c3p0.validate">false</property>


    <property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>
    <property name="hibernate.show_sql">true</property>
    <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>

    <mapping resource etc>
</session-factory>

Can anyone help me on this issue?

解决方案

It happen for many reason like

The database configuration details you have entered are incorrect or have changed, e.g. the database name or database username/password for your Confluence database.

1)The URL for the database is incorrect.

2)The database server is not running. If your database server is down, restart it and check the logs to see why it had failed or stopped.

3)The network is down (or there is a firewall in between confluence and the database server which is interfering) and the connection to the database cannot be established.

4)Your database password has expired.

5)Check your driver,if its present or not in your class-path.

这篇关于现有代码抛出此错误[Hibernate + c3p0 + Oracle11g]:一个资源池无法从其主工厂或源获取资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆