Re: [cx-oracle-users] ping()
Brought to you by:
atuining
From: Paul M. <p.f...@gm...> - 2011-01-17 15:56:54
|
2011/1/17 <prz...@po...>: > I have changed the code to: > > try: > con = cx_Oracle.connect('publikator/gre1czech0@HP_42_OL') > con.ping() > except cx_Oracle.DatabaseError: > #print "*** Connection dropped ***" > STATUS = "DOWN" > else: > STATUS= "UP" > > Should I avoid "cx_Oracle.DatabaseError" in the "except" clause ? I'd personally be inclined to do something like try: con = cx_Oracle.connect('xxx/yyy@zzz') STATUS= "UP" con.close() except cx_Oracle.DatabaseError as ex: # check ex.args[0].code to make sure it's an error that means the DB is down, rather than # something else like incorrect password... if ex.args[0].code in (...): STATUS = "DOWN" else: # Unexpected error - report it somehow (I'll just reraise here) raise except Exception: # Unexpected error - report it somehow (I'll just reraise here - if you are just going # to reraise you can omit this whole clause) raise I tend to be paranoid about not letting unexpected conditions go unreported or caught inappropriately, which is what I suspect is happening to you here. By the way, what results did you get from the tests I suggested below? >> Or your database is actually up... (what Oracle logs are you looking >> at to see that the database is down?) > > alert log Of course even if the alert log shows the database as up, the listener might be down... >> You might want to check that the database is showing as down if you >> connect to it via SQL*Plus. If it is, try the connect() call in the >> interactive interpreter and see what it returns. That may help you to >> diagnose the problem better. Paul. |