KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > resource > adapter > jdbc > vendor > OracleExceptionSorter


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * 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 JavaDoc;
25 import java.sql.SQLException JavaDoc;
26 import org.jboss.resource.adapter.jdbc.ExceptionSorter;
27
28
29 /**
30  * OracleExceptionSorter.java
31  *
32  *
33  * Created: Fri Mar 14 21:54:23 2003
34  *
35  * @author <a HREF="mailto:an_test@mail.ru">Andrey Demchenko</a>
36  * @author <a HREF="mailto:d_jencks@users.sourceforge.net">David Jencks</a>
37  * @author <a HREF="mailto:weston.price@jboss.com>Weston Price</a>
38  * @version 1.0
39  */

40 public class OracleExceptionSorter implements ExceptionSorter, Serializable JavaDoc
41 {
42    private static final long serialVersionUID = 573723525408205079L;
43
44    public OracleExceptionSorter()
45    {
46    }
47
48    public boolean isExceptionFatal(final SQLException JavaDoc e)
49    {
50        final int error_code = Math.abs( e.getErrorCode() ); // I can't remember if the errors are negative or positive.
51

52        if( ( error_code == 28 ) //session has been killed
53
|| ( error_code == 600 ) //Internal oracle error
54
|| ( error_code == 1012 ) //not logged on
55
|| ( error_code == 1014 ) //Oracle shutdown in progress
56
|| ( error_code == 1033 ) //Oracle initialization or shutdown in progress
57
|| ( error_code == 1034 ) //Oracle not available
58
|| ( error_code == 1035 ) //ORACLE only available to users with RESTRICTED SESSION privilege
59
|| ( error_code == 1089 ) //immediate shutdown in progress - no operations are permitted
60
|| ( error_code == 1090 ) //shutdown in progress - connection is not permitted
61
|| ( error_code == 1092 ) //ORACLE instance terminated. Disconnection forced
62
|| ( error_code == 1094 ) //ALTER DATABASE CLOSE in progress. Connections not permitted
63
|| ( error_code == 2396 ) //exceeded maximum idle time, please connect again
64
|| ( error_code == 3106 ) //fatal two-task communication protocol error
65
|| ( error_code == 3111 ) //break received on communication channel
66
|| ( error_code == 3113 ) //end-of-file on communication channel
67
|| ( error_code == 3114 ) //not connected to ORACLE
68
|| ( error_code >= 12100 && error_code <= 12299 ) ) // TNS issues
69
{
70            return true;
71        }
72
73        final String JavaDoc error_text = (e.getMessage()).toUpperCase();
74
75        // Exclude oracle user defined error codes (20000 through 20999) from consideration when looking for
76
// certain strings.
77

78        if( ( error_code < 20000 || error_code >= 21000 ) &&
79              ( (error_text.indexOf("SOCKET") > -1) //for control socket error
80
|| (error_text.indexOf("CONNECTION HAS ALREADY BEEN CLOSED") > -1)
81              || (error_text.indexOf("BROKEN PIPE") > -1) ) )
82        {
83            return true;
84        }
85
86        return false;
87    }
88
89 }
90
Popular Tags