• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Reconnecting to an oracle DB

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My application uses a CustomRegistry on WAS 5 to ensure its security. Works fine most of the time, but if the db is not present at startup, the registry is supposed to loop every 10s to see if the db is back.
The first time, I have the following exception :
java.sql.SQLException: Exception d'E/S: The Network Adapter could not establish the connection
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:404)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:468)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314)
at java.sql.DriverManager.getConnection(DriverManager.java:543)
at java.sql.DriverManager.getConnection(DriverManager.java:194)

Ok, fine, the network cable was purposely unplugged. I plug it back, and every 10s, it still have the same exception : i cannot connect to the database once it has fumbled ...
I can still connect with sqltools, so the db is up. If I stop the application and restart it, it works, so the url, the user and the pass are ok.
Any idea ?
Thanks
 
author & internet detective
Posts: 42165
937
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
Fabien,
Can you post the code segment you use to try the connection? It sounds like you might be repeatedly trying the same connection that doesn't work. The alternative is to close the connection and get a new one or use connection pooling.
 
Fabien Bergeret
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the code :

When I run the class without the network, I have the following trace (which is perfectly normal):

After this exception, I start the network before the second attempt (it is really started since I can connect to the database with SQLTools), and I still have the same exception ...

[ August 11, 2004: Message edited by: Fabien Bergeret ]

[ August 11, 2004: Message edited by: Fabien Bergeret ]

[ August 11, 2004: Message edited by: Fabien Bergeret ]
[ August 11, 2004: Message edited by: Fabien Bergeret ]
 
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Fabien,

As Jeanne says, close the connection (con.close()) when you catch the exception. That should solve the problem. Otherwise your subsequent calls to getConnection() are probably just picking up the broken one.

You might need a little more than 10 seconds for it to recover and connect happily.

Jules
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic