• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to check if DB Connection is LOSTwhen using DATASOURCE

 
Sunitha Mudidani
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi we are using weblogic and oracle server
we are using datasource to obtain connections


The problem is when using a connection,(not getting the connection at the same point)
i will get an SQLException only even if the connection to the WLserver is lost or connection to the database is lost.

In each case i should try to reconnect to the appropriate server. But how do I get to know the source of SQLException ?

One option is checking the errorcode but,

1> is it not vendor dependent?
2> Is this approach correct or any other solution exists?? Point to those resources also, if yes

Pls respond with your valuable suggestions

Thanks
 
Sunitha Mudidani
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any suggestions pls!!
 
Scott Selikoff
author
Saloon Keeper
Posts: 4014
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it sort of vendor dependant although you could construct special cases that try to handle vendors and codes efficiency.

Generally though, I do not follow why you want to decode it. For starters, losing a database connection should be an exception, not the standard. Other than the database going offline, its not easy to lose access. Second, most design patterns encourage transactions. For example, if you lose your database connection halfway through a transaction the correct step is not to check for an active database connection and try to move on without it but to let the exception be thrown so that a transactional rollback is triggered, then recover after the transaction has been terminated.

Back to my original thought, is there a reason you're losing connections? Are you remembering to close them after they are used?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic