Results 1 to 8 of 8

Thread: DataSource.getConnection freezes for 3 min when the db is down

  1. #1

    Default DataSource.getConnection freezes for 3 min when the db is down

    Hi Guys,

    i use oracle.jdbc.pool.OracleDataSource.

    i see that OracleDataSource.getConnection freezes for 3 min when the db is down.

    both loginTimeout and ConnectionWaitTimeout are set.

    i tested it with plain jdbc and it returns after configured timeout.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    Configuration? Please use [ code][ /code] tags when posting that.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3

    Default

    Code:
    <bean id="dataSource" class="oracle.jdbc.pool.OracleDataSource" destroy-method="close">
    <property name="URL">
    <value>${database.url}</value>
    </property>
    <property name="user">
    <value>${database.user}</value>
    </property>
    <property name="password">
    <value>${database.password}</value>
    </property>
    <property name="loginTimeout">
    <value>1</value>
    </property>
    <property name="connectionCachingEnabled">
    <value>true</value>
    </property>
    <property name="connectionCacheName">
    <value>MISConnectionCache</value>
    </property>
    <property name="connectionCacheProperties">
    <props>
    <prop key="MinLimit">10</prop>
    <prop key="MaxLimit">11</prop>
    <prop key="InitialLimit">10</prop>
    <prop key="ConnectionWaitTimeout">1</prop>
    <prop key="MaxStatementsLimit">30</prop>
    </props>
    </property>
    <property name="implicitCachingEnabled">
    <value>true</value>
    </property>
    <property name="maxStatements">
    <value>30</value>
    </property>
    </bean>

  4. #4
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Just off the top of my head, does it wait for every connection it tries to make? e.g. if you set the initial limit to something low would it return quicker?
    Last edited by karldmoore; Aug 30th, 2007 at 06:08 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  5. #5

    Default

    well, once db is down, all connections in connection pool are marked as invalid.
    so, the responce returns immediately untill the connection is taken from the pool. the exception thrown is 'java.sql.SQLException: Closed Connection'.

    when all connections from pool are checked out, next DataSource.getConnection tries to open new connection and then it freezes.
    the exception thrown after that is: 'java.sql.SQLException: Io exception: The Network Adapter could not establish the connection'

  6. #6
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    I would guess there might be another timeout setting e.g. how long to wait when trying to connect.
    Last edited by karldmoore; Aug 30th, 2007 at 06:08 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  7. #7

    Default

    Quote Originally Posted by karldmoore View Post
    I would guess there might be another timeout setting e.g. how long to wait when trying to connect.
    where? In Spring?

    There are such parameters in OracleDataSource:

    connectionWaitTimeout - Time limit to wait, when a new connection request arrives, and there are no connections to check out. It is configured to 1 (sec).

    loginTimeout - The maximum number of millises that the pool will wait for a connection to be returned before throwing an exception. It is configured to 1 (ms).

    It works with plain Jdbc code.

  8. #8
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    No, I specifically meant on the dataSource you are using. I don't really see why you would experience different behviour with or without Spring. The dataSource is the thing that actually manages the connections for you. If you configure this in the same way in both examples I would expect the same behaviour.
    Last edited by karldmoore; Aug 30th, 2007 at 06:07 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •