Re: [cx-oracle-users] best way to detect and recover broken connection?
Brought to you by:
atuining
From: Miguel M. <mi...@yo...> - 2006-12-04 16:46:41
|
Greetings... On Mon, 04 Dec 2006 00:37:28 -0800, Mark Harrison <mh...@pi...> wrote: > Here's kind of a general connection question. > > I've got an application server (xml-rpc based) with > a long-lived persistent connection. Me too... :-) > > Of course, the appserver needs to handle the eventuality > that the connection will be closed at some time. > > What's the best way to handle this? Is there some nice > way to globally catch a disconnection and automatically > reconnect, or some such? > > Many TIA! > Mark > I just set a class variable with errors I think I should reconnect on, # TNS: 12154 12541 12543 12540 # Database: 1014 1033 1034 1035 1089 1090 1092 # Network: 3113 3114 RECONNECTERRORLIST = [ 12154,12541,12543,12540,1014,1033,1034, 1035,1089,1090,1092,3113,3114,3106 ] then in the method that actually performs the Oracle calls I catch the DatabaseError exceptions and check if the Oracle error is in the list (which is probably incomplete) and try to reconnect and redo the query. Hope that's useful. Miguel C. Miguel Marques, Assistant Manager, Software Systems Developer Development Services, Computing & Network Services York University, Toronto, Ontario, Canada e-mail: miguel at yorku.ca, voice: (416)736-2100x22684 |