0

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?

Melvin
  • 377
  • 2
  • 7
  • 19
  • check your logs at WARNING for information about the (last) Exception that persuaded c3p0 to give up trying to acquire Connections. it's probably the logger called `com.mchange.v2.resourcepool.BasicResourcePool`. – Steve Waldman Sep 17 '14 at 10:43
  • at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1422) at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.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(C3P0PooledConnectionPool.java:683) – Melvin Sep 18 '14 at 01:55
  • that's truncated. (perhaps best to edit it into the post rather than put it in a comment. or perhaps i'm seeing it truncated because i'm on the iphone app just now.) you'll need the message farther up and the root cause Exception farther down. – Steve Waldman Sep 18 '14 at 02:00
  • That's the last errors shown in the code, edited the main post. – Melvin Sep 18 '14 at 06:39
  • alas, it remains truncated, there's an Exception beneath, the Exception provoked by the last attempt to get a Connection. maybe you can find a log setting to let more get shown. perhaps more easily, set your log lever for `com.mchange.v2.resourcepool.BasicResourcePool` to FINE or DEBUG and you will see the relevant Exception logged for each acquisition attempt. – Steve Waldman Sep 18 '14 at 09:16

1 Answers1

3

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.

Killer
  • 592
  • 1
  • 6
  • 24
  • check also this http://stackoverflow.com/questions/16528004/a-resourcepool-could-not-acquire-a-resource-from-its-primary-factory-or-source – Killer Sep 17 '14 at 03:47
  • how do i check point no. 5 Check your driver,if its present or not in your class-path. – Melvin Sep 17 '14 at 05:45
  • see this http://stackoverflow.com/questions/13890867/how-to-view-the-contents-of-jar-file-in-eclipse-or-jar-file-explorer – Killer Sep 17 '14 at 05:54
  • i am not sure what's missing even after i added in the jdbc driver. still same error. – Melvin Sep 18 '14 at 06:27
  • see this http://hibernatedb.blogspot.in/2009/05/automatic-reconnect-from-hibernate-to.html – Killer Sep 18 '14 at 06:53
  • aarghh... it was point no 1 1)The URL for the database is incorrect. the dbname supposed to be SID .. – Melvin Sep 18 '14 at 08:20