01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
22: package org.jboss.resource.adapter.jdbc.vendor;
23:
24: import java.io.Serializable;
25: import java.sql.SQLException;
26: import org.jboss.resource.adapter.jdbc.ExceptionSorter;
27:
28: /**
29: * Implementation of ExceptionSorter for Oracle.
30: *
31: * @author <a href="mailto:mark.mcgregor@par3.com">Mark McGregor</a>
32: * @author <a href="mailto:weston.price@jboss.com">Weston Price</a>
33: *
34: */
35: public class OracleExceptionSorter implements ExceptionSorter,
36: Serializable {
37: static final long serialVersionUID = 573723525408205079L;
38:
39: public OracleExceptionSorter() {
40: } // OracleExceptionSorter constructor
41:
42: public boolean isExceptionFatal(final SQLException e) {
43: final int error_code = Math.abs(e.getErrorCode()); // I can't remember if the errors are negative or positive.
44:
45: if ((error_code == 28) //session has been killed
46: || (error_code == 600) //Internal oracle error
47: || (error_code == 1012) //not logged on
48: || (error_code == 1014) //Oracle shutdown in progress
49: || (error_code == 1033) //Oracle initialization or shutdown in progress
50: || (error_code == 1034) //Oracle not available
51: || (error_code == 1035) //ORACLE only available to users with RESTRICTED SESSION privilege
52: || (error_code == 1089) //immediate shutdown in progress - no operations are permitted
53: || (error_code == 1090) //shutdown in progress - connection is not permitted
54: || (error_code == 1092) //ORACLE instance terminated. Disconnection forced
55: || (error_code == 1094) //ALTER DATABASE CLOSE in progress. Connections not permitted
56: || (error_code == 2396) //exceeded maximum idle time, please connect again
57: || (error_code == 3106) //fatal two-task communication protocol error
58: || (error_code == 3111) //break received on communication channel
59: || (error_code == 3113) //end-of-file on communication channel
60: || (error_code == 3114) //not connected to ORACLE
61: || (error_code >= 12100 && error_code <= 12299)) // TNS issues
62: {
63: return true;
64: }
65:
66: final String error_text = (e.getMessage()).toUpperCase();
67:
68: // Exclude oracle user defined error codes (20000 through 20999) from consideration when looking for
69: // certain strings.
70:
71: if ((error_code < 20000 || error_code >= 21000)
72: && ((error_text.indexOf("SOCKET") > -1) //for control socket error
73: || (error_text
74: .indexOf("CONNECTION HAS ALREADY BEEN CLOSED") > -1) || (error_text
75: .indexOf("BROKEN PIPE") > -1))) {
76: return true;
77: }
78:
79: return false;
80: }
81: }
|