1 | /* |
2 | |
3 | Derby - Class org.apache.derby.impl.tools.ij.ijException |
4 | |
5 | Copyright 1997, 2004 The Apache Software Foundation or its licensors, as applicable. |
6 | |
7 | Licensed under the Apache License, Version 2.0 (the "License"); |
8 | you may not use this file except in compliance with the License. |
9 | You may obtain a copy of the License at |
10 | |
11 | http://www.apache.org/licenses/LICENSE-2.0 |
12 | |
13 | Unless required by applicable law or agreed to in writing, software |
14 | distributed under the License is distributed on an "AS IS" BASIS, |
15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | See the License for the specific language governing permissions and |
17 | limitations under the License. |
18 | |
19 | */ |
20 | |
21 | package org.apache.derby.impl.tools.ij; |
22 | |
23 | import org.apache.derby.iapi.tools.i18n.LocalizedResource; |
24 | import java.io.IOException; |
25 | |
26 | /** |
27 | ijException is used to get messages from the ij parser to |
28 | the main ij loop. Because this is not under the protocol/impl |
29 | umbrella, it does not have available to it the message service. |
30 | At this time, all messages are hard-coded in this file. A more |
31 | serviceable solution may need to be found. |
32 | |
33 | @author ames. |
34 | */ |
35 | |
36 | public class ijException extends RuntimeException { |
37 | |
38 | private final static String IllegalStatementName="IJ_IllegalStatementName"; |
39 | private final static String NotYetImplemented="IJ_NotYetImpl"; |
40 | private final static String AlreadyHaveConnectionNamed = "IJ_AlreHaveACon"; |
41 | private final static String BangException = "IJ_ExceRunnComm"; |
42 | private final static String ConnectionGetWarningsFailed = "IJ_UnabToGetWar"; |
43 | private final static String ClassNotFoundForProtocol = "IJ_CoulNotLocaC"; |
44 | private final static String ClassNotFound = "IJ_CoulNotLocaC_5"; |
45 | private final static String DisconnectFailed = "IJ_FailToDisc"; |
46 | private final static String DriverNotClassName = "IJ_DrivNotClasN"; |
47 | private final static String FileNotFound = "IJ_FileNotFoun"; |
48 | private final static String ForwardOnlyCursor = "IJ_IsNotAlloOnA"; |
49 | private final static String GetConnectionFailed = "IJ_GetcCallFail"; |
50 | private final static String IOException = "IJ_Ioex"; |
51 | private final static String NeedToDisconnect = "IJ_NeedToDiscFi"; |
52 | private final static String NoSuchAsyncStatement = "IJ_NoAsynStatEx"; |
53 | private final static String NoSuchConnection = "IJ_NoConnExisWi"; |
54 | private final static String NoSuchProtocol = "IJ_NoProtExisWi"; |
55 | private final static String NotJDBC20 = "IJ_IsOnlySuppIn"; |
56 | private final static String NoUsingResults = "IJ_UsinClauHadN"; |
57 | private final static String ObjectWasNull = "IJ_UnabToEsta"; |
58 | private final static String ResultSetGetWarningsFailed = "IJ_UnabToGetWar_19"; |
59 | private final static String ResourceNotFound = "IJ_ResoNotFoun"; |
60 | private final static String ScrollCursorsNotSupported = "IJ_ScroCursAre1"; |
61 | private final static String HoldCursorsNotSupported = "IJ_HoldCursAre4"; |
62 | private final static String StatementGetWarningsFailed = "IJ_UnabToGetWar_22"; |
63 | private final static String WaitInterrupted = "IJ_WaitForStatI"; |
64 | private final static String ZeroInvalidForAbsolute = "IJ_0IsAnInvaVal"; |
65 | |
66 | public ijException(String message) { |
67 | super(message); |
68 | } |
69 | |
70 | static ijException notYetImplemented() { |
71 | return new ijException(LocalizedResource.getMessage(NotYetImplemented)); |
72 | } |
73 | |
74 | static ijException illegalStatementName(String n) { |
75 | return new ijException(LocalizedResource.getMessage(IllegalStatementName, n)); |
76 | } |
77 | static ijException alreadyHaveConnectionNamed(String n) { |
78 | return new ijException(LocalizedResource.getMessage(AlreadyHaveConnectionNamed, n)); |
79 | } |
80 | static ijException bangException(Throwable t) { |
81 | return new ijException(LocalizedResource.getMessage(BangException, t.toString())); |
82 | } |
83 | static ijException classNotFoundForProtocol(String p) { |
84 | return new ijException(LocalizedResource.getMessage(ClassNotFoundForProtocol, p)); |
85 | } |
86 | static ijException classNotFound(String c) { |
87 | return new ijException(LocalizedResource.getMessage(ClassNotFound, c)); |
88 | } |
89 | static ijException connectionGetWarningsFailed() { |
90 | return new ijException(LocalizedResource.getMessage(ConnectionGetWarningsFailed)); |
91 | } |
92 | static ijException disconnectFailed() { |
93 | return new ijException(LocalizedResource.getMessage(DisconnectFailed)); |
94 | } |
95 | static ijException driverNotClassName(String c) { |
96 | return new ijException(LocalizedResource.getMessage(DriverNotClassName, c)); |
97 | } |
98 | static ijException fileNotFound() { |
99 | return new ijException(LocalizedResource.getMessage(FileNotFound)); |
100 | } |
101 | static public ijException forwardOnlyCursor(String operation) { |
102 | return new ijException(LocalizedResource.getMessage(ForwardOnlyCursor, operation)); |
103 | } |
104 | static ijException resourceNotFound() { |
105 | return new ijException(LocalizedResource.getMessage(ResourceNotFound)); |
106 | } |
107 | static ijException getConnectionFailed() { |
108 | return new ijException(LocalizedResource.getMessage(GetConnectionFailed)); |
109 | } |
110 | static ijException iOException(IOException t) { |
111 | return new ijException(LocalizedResource.getMessage(IOException, t.getMessage())); |
112 | } |
113 | static ijException needToDisconnect() { |
114 | return new ijException(LocalizedResource.getMessage(NeedToDisconnect)); |
115 | } |
116 | static ijException noSuchAsyncStatement(String c) { |
117 | return new ijException(LocalizedResource.getMessage(NoSuchAsyncStatement, c)); |
118 | } |
119 | static ijException noSuchConnection(String c) { |
120 | return new ijException(LocalizedResource.getMessage(NoSuchConnection, c)); |
121 | } |
122 | static ijException noSuchProtocol(String c) { |
123 | return new ijException(LocalizedResource.getMessage(NoSuchProtocol, c)); |
124 | } |
125 | static public ijException notJDBC20(String operation) { |
126 | return new ijException(LocalizedResource.getMessage(NotJDBC20, operation)); |
127 | } |
128 | static ijException noUsingResults() { |
129 | return new ijException(LocalizedResource.getMessage(NoUsingResults)); |
130 | } |
131 | static public ijException objectWasNull(String objectName) { |
132 | return new ijException(LocalizedResource.getMessage(ObjectWasNull, objectName)); |
133 | } |
134 | static ijException resultSetGetWarningsFailed() { |
135 | return new ijException(LocalizedResource.getMessage(ResultSetGetWarningsFailed)); |
136 | } |
137 | static ijException scrollCursorsNotSupported() { |
138 | return new ijException(LocalizedResource.getMessage(ScrollCursorsNotSupported)); |
139 | } |
140 | //IJImpl20.utilMain can't throw exception for holdable cursors if |
141 | //following not declared public |
142 | public static ijException holdCursorsNotSupported() { |
143 | return new ijException(LocalizedResource.getMessage(HoldCursorsNotSupported)); |
144 | } |
145 | static ijException statementGetWarningsFailed() { |
146 | return new ijException(LocalizedResource.getMessage(StatementGetWarningsFailed)); |
147 | } |
148 | static ijException waitInterrupted(Throwable t) { |
149 | return new ijException(LocalizedResource.getMessage(WaitInterrupted, t.toString())); |
150 | } |
151 | public static ijException zeroInvalidForAbsolute() { |
152 | return new ijException(LocalizedResource.getMessage(ZeroInvalidForAbsolute)); |
153 | } |
154 | } |