Results 1 to 5 of 5

Thread: Recovery from a lost database connection

  1. #1
    Join Date
    Feb 2005
    Location
    Boston, MA
    Posts
    1,142

    Default Recovery from a lost database connection

    I am developing database code which will run on a Oracle 10g RAC. Someone has asked if its possible for the Spring jdbc classes to recover when a node in a RAC goes down, such that the connection is reastablished and then all the statement creation is rerun and the statement is reexecuted automatically without having to write application level code. Right now we have code in various places of our non-Spring JDBC code which doesn't handle it in a generic fashion.

    I am particularly concerned about being to able to reregistering TypeMaps for the newly recreated Connection.

    Any help would be appreciated.

  2. #2
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    You will need to write application code to handle this. For example:
    Code:
    try {
       doThingsWithSpringJdbc();
    }
    catch (CannotGetJdbcConnectionException ex) {
       // recover here
       // you should be able to use Spring JDBC again, as it should try
       // to obtain another connection from the DataSource
    }
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

  3. #3
    Join Date
    Aug 2004
    Posts
    1,107

    Default

    If you are using a connection pool, then this would be the responibility of the connection pool implementation. Each operation in the spring data access layer obtains a connection from the pool and returns it when the operation completes, so unless the connection pool cooperates, you might not be able to control the connections from your application code.
    Thomas Risberg
    SpringSource by Pivotal
    http://www.springsource.org

  4. #4
    Join Date
    Feb 2005
    Location
    Boston, MA
    Posts
    1,142

    Default

    It looks like overriding JdbcTemplate might do the trick for me. I noticed that all JdbcTemplate operations call one of the following:

    Code:
    execute CallableStatementCreator, CallableStatementCallback)
    execute(ConnectionCallback)
    execute(PreparedStatementCreator, PreparedStatementCallback)
    execute(StatementCallback)
    Each of them create a connection and execute the statments created.

    Either create a custom class which wraps each of these operations in a try/catch logic and reexecute the command when certain exceptions are thrown, or use Spring AOP to inject the proper code into the existing JdbcTemplate class.

    What do people think?

  5. #5
    Join Date
    Aug 2004
    Location
    Leuven, Belgium
    Posts
    37

    Default

    Interesting... We're also running on Oracle 10g RAC and my boss would
    really like such a feature, although I am quite sceptic.
    I think we're never gonna use it in reality and it will complicate things.
    But please, let us know your experience.

    Succes,
    Maarten

Similar Threads

  1. Replies: 2
    Last Post: Nov 22nd, 2006, 01:38 PM
  2. Replies: 1
    Last Post: Oct 2nd, 2005, 10:16 AM
  3. Replies: 1
    Last Post: Aug 18th, 2005, 05:58 AM
  4. Database Connection Not Released
    By pcheung in forum Data
    Replies: 2
    Last Post: Mar 18th, 2005, 09:19 AM
  5. Replies: 5
    Last Post: Dec 22nd, 2004, 08:27 AM

Posting Permissions

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