Results 1 to 9 of 9

Thread: DB Connection lost - after DB Server reboot

  1. #1
    Join Date
    Apr 2006
    Posts
    5

    Default DB Connection lost - after DB Server reboot

    Hi,

    i develop a web application on WebSphere 5.1 and every night the db server goes down for backup. after that on every sql call i get

    Code:
    org.springframework.dao.DataAccessResourceFailureException: PreparedStatementCallback; SQL [SELECT * FROM foo where bar order by foobar desc]; Io exception: There is no process to read data written to a pipe.; nested exception is java.sql.SQLException: Io exception: There is no process to read data written to a pipe.
         org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:231)
         org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java(Compiled Code))
         org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java(Compiled Code))
         org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java(Inlined Compiled Code))
         org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java(Inlined Compiled Code))
         org.springframework.jdbc.object.SqlQuery.execute(SqlQuery.java(Inlined Compiled Code))
         org.springframework.jdbc.object.SqlQuery.execute(SqlQuery.java(Inlined Compiled Code))
         org.springframework.jdbc.object.SqlQuery.execute(SqlQuery.java(Compiled Code))
    until i reboot the webapp.


    my question is how do i get spring to reconnect to my oracle DB.

    cheerio
    gabe

  2. #2
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    Actually this is no Spring issue. It has to do with the configuration of your connection pool. You have to configure your connection pool to perform a check on the pooled connections (either on hand-out or periodically). This is the only way to find out if connections are broken. Maybe you have to use another connection pool if your implementation does not support this.

    One pool implementation I know is able to perform checks is c3p0.

    Regards,
    Andreas

  3. #3
    Join Date
    Apr 2006
    Posts
    5

    Default

    thank you for replying.

    but isnt the websphere connection pool the one who should do those things?

    is it possible to use c3p0 and the websphere jndi datasource?

  4. #4
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    Quote Originally Posted by gabe12
    but isnt the websphere connection pool the one who should do those things?
    Yes you are right. It seems I overlooked that part in your post.

    Nevertheless it is true that you have to configure the appropriate settings. I have not worked with Websphere yet, but from Weblogic I know that such checks are disabled by default.
    So have a look at your appserver's connection-pool configuration and see how to enable the appropriate checks.

    Regards,
    Andreas

  5. #5
    Join Date
    Apr 2006
    Posts
    5

    Default

    i found some promising properties

    it is possible to change the purge policy from
    Code:
    failingConnectionOnly
    to
    Code:
    entirePool
    and it there is a property called
    Code:
    preTestSQLString
    where an sql statement can be passed to validate the connections.

    i'll give it a try and will report the sucess or failures ;-)

  6. #6
    Join Date
    Apr 2006
    Posts
    5

    Default

    it did not work.

    i think this is an application issue not configuration.

    websphere is known to keep the stale connections.

  7. #7
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    Does your application require distributed transactions, or do you access only a single database?

    In the latter case you could as well dismiss the container configured datasource and define one yourself in your application context. In that case you could use a pooling implementation that provides a working connection checking like, say, c3p0.

    Regards,
    Andreas

  8. #8
    Join Date
    Apr 2006
    Posts
    5

    Default

    i'll try c3p0.

    sounds simple and good.

  9. #9
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    c3p0 documentation is pretty straight forward and you should not have any problems setting it up. However, if you have, search the forum - you should find examples for c3p0 and also commons-dbcp.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Posting Permissions

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