The automatic database reconnection feature in WebObjects 4.5 fails to reconnect a client to the host Oracle database.
Solution
There are only six predefined Oracle error codes recognized by WebObjects as connection failures. When any Oracle error code other than these six occurs, the OracleAdaptor method isDroppedConnectionException returns NO/False. By default, when isDroppedConnectionException returns NO, no reconnection is attempted, and the original exception is raised as usual.
For additional error codes to be recognized, they need to be added to the WebObjects Framework and recompiled.
Recognized Oracle Error codes
2. ORA-00030: user session ID does not exist
3. ORA-00051: time-out occurred while waiting for resource
4. ORA-00060: deadlock detected while waiting for resource
5. ORA-00099: timed out while waiting for resource, potential PDML deadlock
6. ORA-01012: not logged on
Adding Additional Error Codes
To change the default behavior, include this Objective C category to your project, and add the error code. Once the error code is added, Enterprise Object Framework (EOF) will attempt an automatic reconnection.
You must add the OracleEOAdaptor.framework to the list of frameworks in your project to recompile your project successfully.
------File OracleConnectionErrorAdditions.m----------------
#include <OracleEOAdaptor/OracleAdaptor.h>
@implementation
OracleAdaptor(OracleConnectionErrorAdditions)
- (BOOL)isDroppedConnectionException:(NSException
*)exception
{
NSDictionary *userInfo = [exception userInfo];
if (userInfo) {
int errCode = [[userInfo
objectForKey:OracleErrorKey] intValue];
// 00028 session killed
// 00030 user session no longer exists
// 00051 time out
// 00060 deadlock
// 00099 PDML deadlock
// 01012 not logged on
switch (errCode) {
case 28:
case 30:
case 51:
case 60:
case 1012:
case 99:
// ADD YOUR ERROR CODE HERE. FOR EXAMPLE ORA-01041:
// ORA-01041: internal error. HOSTDEF extension
does not exist
case 1041:
return YES;
// Yes, the exception comes from a dropped connection
default:
return NO;
// adaptor should NOT try to reconnect, and should re-raise the exception
}
}
return NO;
}
@end
-----------------------------------------------------------