How do I decrease the timeouts to create a c3p0 ComboPooledDataSource and get an Oracle db connection?

user506069

I have a pretty simple Hibernate project which connects to an Oracle database.

If for some reason it is unable to connect to Oracle (like if the network is down), it will take over a minute to fail. This occurs while building the data source and seems to occur when trying to interact with the database as well.

I would like to change the settings for it to fail in a few seconds. After changing what I believe are the relevant settings, nothing seems to change. It's like my configuration is being ignored.

Relevant portions of the Spring file doing my dependency injection, appContext.xml:

<bean id="oracleDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" 
    destroy-method="close">
    <property name="driverClass" value="oracle.jdbc.OracleDriver"/>
    <property name="jdbcUrl" value="jdbc:oracle:thin:@****"/>
    <property name="user" value="****"/>
    <property name="password" value="****"/>
</bean>

<bean id="oracleSessionFactory" 
    class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource" ref="oracleDataSource"/>
    <property name="configLocation">
        <value>classpath:oracle.hibernate.cfg.xml</value>
    </property>
</bean>

And my hibernate configuration file: oracle.hibernate.cfg.xml:

<?xml version="1.0"?>
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>
        <property name="hibernate.c3p0.max_size">1</property>
        <property name="hibernate.c3p0.checkoutTimeout">5000</property>
        <property name="hibernate.c3p0.acquireRetryAttempts">0</property>
        <property name="show_sql">true</property>
        <mapping class="****"/>
    </session-factory>
</hibernate-configuration>

I have heard this can be caused by not having hibernate-c3p0-version.jar in the classpath, so here are the classpath settings for my test...

Classpath settings for my test

...and here is where hibernate-c3p0-4.2.11.Final.jar is specified in my Maven pom.xml:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-c3p0</artifactId>
    <version>4.2.11.Final</version>
</dependency>
M. Deinum

You are using an injected DataSource in your configuration. Trying to add configuration to hibernate isn't going to help as hibernate isn't in control of the datasource. Set the properties on the Spring configured ComboPooledDataSource.

<bean id="oracleDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
    <property name="driverClass" value="oracle.jdbc.OracleDriver"/>
    <property name="jdbcUrl" value="jdbc:oracle:thin:@****"/>
    <property name="user" value="****"/>
    <property name="password" value="****"/>
    <property name="acquireRetryAttempts" value="0"/>
    <property name="checkoutTimeout" value="5000"/>       
</bean>

Remove the hibernate.c3p0 properties from your hibernate configuration as well as the added dependency as that isn't going to be used.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I decrease the timeouts to create a c3p0 ComboPooledDataSource and get an Oracle db connection?

From Dev

How can I mock a c3p0 ComboPooledDataSource

From Dev

c3p0 connection pooling, DataSources factory, how do I close the pool?

From Dev

How do I deal with dequeue connection timeouts in rails/mongoid?

From Dev

Will C3P0 ComboPooledDataSource getConnection() always return valid Connection?

From Dev

How do I get provider name to open Ole DB connection?

From Dev

c3p0 connection Pooling error - Oracle RAC

From Dev

How do I simulate connection errors and request timeouts in python unit tests

From Dev

Mysql 8.0.11 with Hibernate and C3P0: How do I disable connecting through SSL?

From Dev

Sometimes Hibernate can not get connection by C3P0

From Dev

Why i get the connection string error when connect the oracle DB with c#?

From Dev

How configure connection existence check in C3P0?

From Dev

How to handle connection pooling with c3p0

From Dev

How do I decrease the minimum font size in Sublime Text 3

From Dev

How can i get the password of oracle user instance from oracle connection string using C#?

From Dev

C3p0 trying to create a new connection pool and failing with ClassNotFoundException

From Dev

how to do Pagination connection with DB static Connection

From Dev

how can I decrease the size of the final package of the Oracle MAF applications?

From Dev

How do I decrease the size of Icon in openlayers 3, i am using bing maps

From Dev

How do I create a user that can create users in Oracle 12c?

From Dev

How to use C3P0 in a spring boot hibernate multi tenant application to manage connection pool?

From Dev

How to make Hibernate SessionFactory checkout JDBC connection from c3p0 upon session opening?

From Dev

CLOB : JdbcTemplate : c3p0 - how reuse the same connection?

From Dev

How to find which application created each c3p0 connection pool?

From Dev

How do I access an Oracle db without installing Oracle's client and cx_Oracle?

From Dev

I have the information, how do I get it into my db?

From Dev

How do I create a partitioned collection in Cosmos DB with pydocumentdb?

From Dev

How to confiure the JDBC URL with service name when use C3P0 CONNECT oracle database?

From Dev

How to confiure the JDBC URL with service name when use C3P0 CONNECT oracle database?

Related Related

  1. 1

    How do I decrease the timeouts to create a c3p0 ComboPooledDataSource and get an Oracle db connection?

  2. 2

    How can I mock a c3p0 ComboPooledDataSource

  3. 3

    c3p0 connection pooling, DataSources factory, how do I close the pool?

  4. 4

    How do I deal with dequeue connection timeouts in rails/mongoid?

  5. 5

    Will C3P0 ComboPooledDataSource getConnection() always return valid Connection?

  6. 6

    How do I get provider name to open Ole DB connection?

  7. 7

    c3p0 connection Pooling error - Oracle RAC

  8. 8

    How do I simulate connection errors and request timeouts in python unit tests

  9. 9

    Mysql 8.0.11 with Hibernate and C3P0: How do I disable connecting through SSL?

  10. 10

    Sometimes Hibernate can not get connection by C3P0

  11. 11

    Why i get the connection string error when connect the oracle DB with c#?

  12. 12

    How configure connection existence check in C3P0?

  13. 13

    How to handle connection pooling with c3p0

  14. 14

    How do I decrease the minimum font size in Sublime Text 3

  15. 15

    How can i get the password of oracle user instance from oracle connection string using C#?

  16. 16

    C3p0 trying to create a new connection pool and failing with ClassNotFoundException

  17. 17

    how to do Pagination connection with DB static Connection

  18. 18

    how can I decrease the size of the final package of the Oracle MAF applications?

  19. 19

    How do I decrease the size of Icon in openlayers 3, i am using bing maps

  20. 20

    How do I create a user that can create users in Oracle 12c?

  21. 21

    How to use C3P0 in a spring boot hibernate multi tenant application to manage connection pool?

  22. 22

    How to make Hibernate SessionFactory checkout JDBC connection from c3p0 upon session opening?

  23. 23

    CLOB : JdbcTemplate : c3p0 - how reuse the same connection?

  24. 24

    How to find which application created each c3p0 connection pool?

  25. 25

    How do I access an Oracle db without installing Oracle's client and cx_Oracle?

  26. 26

    I have the information, how do I get it into my db?

  27. 27

    How do I create a partitioned collection in Cosmos DB with pydocumentdb?

  28. 28

    How to confiure the JDBC URL with service name when use C3P0 CONNECT oracle database?

  29. 29

    How to confiure the JDBC URL with service name when use C3P0 CONNECT oracle database?

HotTag

Archive