KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > triactive > jdo > store > PostgreSQLSQLState


1 /*
2  * Copyright 2003 (C) TJDO.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the TJDO License version 1.0.
6  * See the terms of the TJDO License in the documentation provided with this software.
7  *
8  * $Id: PostgreSQLSQLState.java,v 1.1 2003/10/18 19:54:01 jackknifebarber Exp $
9  */

10
11 package com.triactive.jdo.store;
12
13 import java.util.Arrays JavaDoc;
14
15
16 /**
17  * A SQLSTATE diagnostic code for PostgreSQL.
18  *
19  * @author <a HREF="mailto:mmartin5@austin.rr.com">Mike Martin</a>
20  * @version $Revision: 1.1 $
21  *
22  * @see DatabaseAdapter
23  */

24
25 public class PostgreSQLSQLState extends SQLState
26 {
27     /**
28      * Constructs a SQLState object from the specified SQLSTATE string.
29      *
30      * @param s
31      * A 5-character SQLSTATE string.
32      *
33      * @exception IllegalArgumentException
34      * if <var>s</var> is not a valid 5-character SQLSTATE string.
35      */

36
37     public PostgreSQLSQLState(String JavaDoc s) throws IllegalArgumentException JavaDoc
38     {
39     super(s);
40     }
41
42
43     public boolean isWorthRetrying()
44     {
45         if (Arrays.binarySearch(ClassCode.NOT_RETRYABLE, classCode()) >= 0)
46             return false;
47         else
48             return true;
49     }
50
51
52     /**
53      * Contains constants for known SQLSTATE class codes.
54      * This list comes from pgsql/src/include/utils/errcodes.h
55      */

56
57     public static class ClassCode
58     {
59         /** Private constructor prevents instantiation. */
60         private ClassCode() {}
61
62         public static final String JavaDoc
63             SUCCESSFUL_COMPLETION = "00",
64             WARNING = "01",
65             NO_DATA = "02",
66             SQL_STATEMENT_NOT_YET_COMPLETE = "03",
67             CONNECTION_EXCEPTION = "08",
68             TRIGGERED_ACTION_EXCEPTION = "09",
69             FEATURE_NOT_SUPPORTED = "0A",
70             INVALID_TRANSACTION_INITIATION = "0B",
71             LOCATOR_EXCEPTION = "0F",
72             INVALID_GRANTOR = "0L",
73             INVALID_ROLE_SPECIFICATION = "0P",
74             CARDINALITY_VIOLATION = "21",
75             DATA_EXCEPTION = "22",
76             INTEGRITY_CONSTRAINT_VIOLATION = "23",
77             INVALID_CURSOR_STATE = "24",
78             INVALID_TRANSACTION_STATE = "25",
79             INVALID_SQL_STATEMENT_NAME = "26",
80             TRIGGERED_DATA_CHANGE_VIOLATION = "27",
81             INVALID_AUTHORIZATION_SPECIFICATION = "28",
82             DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST = "2B",
83             INVALID_TRANSACTION_TERMINATION = "2D",
84             SQL_ROUTINE_EXCEPTION = "2F",
85             INVALID_CURSOR_NAME = "34",
86             EXTERNAL_ROUTINE_EXCEPTION = "38",
87             EXTERNAL_ROUTINE_INVOCATION_EXCEPTION = "39",
88             INVALID_CATALOG_NAME = "3D",
89             INVALID_SCHEMA_NAME = "3F",
90             TRANSACTION_ROLLBACK = "40",
91             SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION = "42",
92             WITH_CHECK_OPTION_VIOLATION = "44",
93             INSUFFICIENT_RESOURCES = "53",
94             PROGRAM_LIMIT_EXCEEDED = "54",
95             OBJECT_NOT_IN_PREREQUISITE_STATE = "55",
96             OPERATOR_INTERVENTION = "57",
97             SYSTEM_ERROR = "58",
98             CONFIG_FILE_ERROR = "F0",
99             INTERNAL_ERROR = "XX";
100
101         /**
102          * An array representing all those class codes that are known
103          * <em>not</em> to be worth retrying.
104          * The array is sorted for efficient searching.
105          */

106         public static final String JavaDoc[] NOT_RETRYABLE =
107         {
108             /* Take care to keep this list sorted by value. */
109             SUCCESSFUL_COMPLETION,
110             WARNING,
111             NO_DATA,
112             SQL_STATEMENT_NOT_YET_COMPLETE,
113             //CONNECTION_EXCEPTION,
114
TRIGGERED_ACTION_EXCEPTION,
115             FEATURE_NOT_SUPPORTED,
116             INVALID_TRANSACTION_INITIATION,
117             LOCATOR_EXCEPTION,
118             INVALID_GRANTOR,
119             INVALID_ROLE_SPECIFICATION,
120             CARDINALITY_VIOLATION,
121             DATA_EXCEPTION,
122             INTEGRITY_CONSTRAINT_VIOLATION,
123             //INVALID_CURSOR_STATE,
124
//INVALID_TRANSACTION_STATE,
125
INVALID_SQL_STATEMENT_NAME,
126             TRIGGERED_DATA_CHANGE_VIOLATION,
127             INVALID_AUTHORIZATION_SPECIFICATION,
128             DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST,
129             //INVALID_TRANSACTION_TERMINATION,
130
SQL_ROUTINE_EXCEPTION,
131             INVALID_CURSOR_NAME,
132             EXTERNAL_ROUTINE_EXCEPTION,
133             EXTERNAL_ROUTINE_INVOCATION_EXCEPTION,
134             INVALID_CATALOG_NAME,
135             INVALID_SCHEMA_NAME,
136             //TRANSACTION_ROLLBACK,
137
SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION,
138             WITH_CHECK_OPTION_VIOLATION,
139             //INSUFFICIENT_RESOURCES,
140
PROGRAM_LIMIT_EXCEEDED,
141             //OBJECT_NOT_IN_PREREQUISITE_STATE,
142
//OPERATOR_INTERVENTION,
143
//SYSTEM_ERROR,
144
CONFIG_FILE_ERROR,
145             INTERNAL_ERROR
146         };
147     }
148 }
149
Popular Tags