• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Getting Stale Connection using OracleDataSource with OCI driver - Please Help URGENT

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am getting stale connection error when there is no requests to the database from my java application for couple of hours.

Little background about my application:
Its a simple java application runned on Linux box with OCI (type driver). Dont ask me why OCI, why not thin. I am using OracleDataSource and OracleConnectionCacheManager for maintaining the cache of connection objects. Here is the code snippet:


The error is as follows:

ConnectionManager.java:getConnection:87 - Exception while getting Connection object:
java.sql.SQLException: Invalid or Stale Connection found in the Connection Cache
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
at oracle.jdbc.pool.OracleImplicitConnectionCache.getConnection(OracleImplicitConnectionCache.java:390)
at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:404)
at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:189)

Please let me know what am i missing. I will be very thankful to you.

Many THanks
true friend




[added code tags]
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does the caller of this code close the connection when done with it?

Another possibility that your datasource is not sized correctly. Some datasources need the minimum size to zero or they hang on to open connections.
 
Caeser smith
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote:Does the caller of this code close the connection when done with it?

Another possibility that your datasource is not sized correctly. Some datasources need the minimum size to zero or they hang on to open connections.



Hi Jeanne,

Thanks for your reply.
The caller code is closing the connection object. I am pretty sure about it. After some research, i have found the same suggestion as you mentioned above(making the minimum size to zero).

I have talked to my DBA and according to him on the database, the connection objects are closed if they are idle for 30 mins. My pool minimum size is 1, hence if there is no requests to the DB for more than 30 mins, that connection object is becoming stale.

Having said that, I am still not able to understand the functionality of refreshCache(), why it is not refreshing the invalid connections.

Any comments on this will be appreciated. thanks
reply
    Bookmark Topic Watch Topic
  • New Topic