001: /*
002:
003: Derby - Class org.apache.derby.impl.tools.ij.ijException
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to You under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.impl.tools.ij;
023:
024: import org.apache.derby.iapi.tools.i18n.LocalizedResource;
025: import java.io.IOException;
026:
027: /**
028: ijException is used to get messages from the ij parser to
029: the main ij loop. Because this is not under the protocol/impl
030: umbrella, it does not have available to it the message service.
031: At this time, all messages are hard-coded in this file. A more
032: serviceable solution may need to be found.
033:
034: @author ames.
035: */
036:
037: public class ijException extends RuntimeException {
038:
039: private final static String IllegalStatementName = "IJ_IllegalStatementName";
040: private final static String NotYetImplemented = "IJ_NotYetImpl";
041: private final static String AlreadyHaveConnectionNamed = "IJ_AlreHaveACon";
042: private final static String BangException = "IJ_ExceRunnComm";
043: private final static String ConnectionGetWarningsFailed = "IJ_UnabToGetWar";
044: private final static String ClassNotFoundForProtocol = "IJ_CoulNotLocaC";
045: private final static String ClassNotFound = "IJ_CoulNotLocaC_5";
046: private final static String DisconnectFailed = "IJ_FailToDisc";
047: private final static String DriverNotClassName = "IJ_DrivNotClasN";
048: private final static String FileNotFound = "IJ_FileNotFoun";
049: private final static String ForwardOnlyCursor = "IJ_IsNotAlloOnA";
050: private final static String GetConnectionFailed = "IJ_GetcCallFail";
051: private final static String IOException = "IJ_Ioex";
052: private final static String NeedToDisconnect = "IJ_NeedToDiscFi";
053: private final static String NoSuchAsyncStatement = "IJ_NoAsynStatEx";
054: private final static String NoSuchConnection = "IJ_NoConnExisWi";
055: private final static String NoSuchProtocol = "IJ_NoProtExisWi";
056: private final static String NoSuchTable = "IJ_NoSuchTable";
057: private final static String NotJDBC20 = "IJ_IsOnlySuppIn";
058: private final static String NoUsingResults = "IJ_UsinClauHadN";
059: private final static String ObjectWasNull = "IJ_UnabToEsta";
060: private final static String ResultSetGetWarningsFailed = "IJ_UnabToGetWar_19";
061: private final static String ResourceNotFound = "IJ_ResoNotFoun";
062: private final static String ScrollCursorsNotSupported = "IJ_ScroCursAre1";
063: private final static String HoldCursorsNotSupported = "IJ_HoldCursAre4";
064: private final static String StatementGetWarningsFailed = "IJ_UnabToGetWar_22";
065: private final static String WaitInterrupted = "IJ_WaitForStatI";
066: private final static String ZeroInvalidForAbsolute = "IJ_0IsAnInvaVal";
067:
068: public ijException(String message) {
069: super (message);
070: }
071:
072: static ijException notYetImplemented() {
073: return new ijException(LocalizedResource
074: .getMessage(NotYetImplemented));
075: }
076:
077: static ijException illegalStatementName(String n) {
078: return new ijException(LocalizedResource.getMessage(
079: IllegalStatementName, n));
080: }
081:
082: static ijException alreadyHaveConnectionNamed(String n) {
083: return new ijException(LocalizedResource.getMessage(
084: AlreadyHaveConnectionNamed, n));
085: }
086:
087: static ijException bangException(Throwable t) {
088: return new ijException(LocalizedResource.getMessage(
089: BangException, t.toString()));
090: }
091:
092: static ijException classNotFoundForProtocol(String p) {
093: return new ijException(LocalizedResource.getMessage(
094: ClassNotFoundForProtocol, p));
095: }
096:
097: static ijException classNotFound(String c) {
098: return new ijException(LocalizedResource.getMessage(
099: ClassNotFound, c));
100: }
101:
102: static ijException connectionGetWarningsFailed() {
103: return new ijException(LocalizedResource
104: .getMessage(ConnectionGetWarningsFailed));
105: }
106:
107: static ijException disconnectFailed() {
108: return new ijException(LocalizedResource
109: .getMessage(DisconnectFailed));
110: }
111:
112: static ijException driverNotClassName(String c) {
113: return new ijException(LocalizedResource.getMessage(
114: DriverNotClassName, c));
115: }
116:
117: static ijException fileNotFound() {
118: return new ijException(LocalizedResource
119: .getMessage(FileNotFound));
120: }
121:
122: static public ijException forwardOnlyCursor(String operation) {
123: return new ijException(LocalizedResource.getMessage(
124: ForwardOnlyCursor, operation));
125: }
126:
127: static ijException resourceNotFound() {
128: return new ijException(LocalizedResource
129: .getMessage(ResourceNotFound));
130: }
131:
132: static ijException getConnectionFailed() {
133: return new ijException(LocalizedResource
134: .getMessage(GetConnectionFailed));
135: }
136:
137: static ijException iOException(IOException t) {
138: return new ijException(LocalizedResource.getMessage(
139: IOException, t.getMessage()));
140: }
141:
142: static ijException needToDisconnect() {
143: return new ijException(LocalizedResource
144: .getMessage(NeedToDisconnect));
145: }
146:
147: static ijException noSuchAsyncStatement(String c) {
148: return new ijException(LocalizedResource.getMessage(
149: NoSuchAsyncStatement, c));
150: }
151:
152: static ijException noSuchConnection(String c) {
153: return new ijException(LocalizedResource.getMessage(
154: NoSuchConnection, c));
155: }
156:
157: static ijException noSuchProtocol(String c) {
158: return new ijException(LocalizedResource.getMessage(
159: NoSuchProtocol, c));
160: }
161:
162: static ijException noSuchTable(String c) {
163: return new ijException(LocalizedResource.getMessage(
164: NoSuchTable, c));
165: }
166:
167: static public ijException notJDBC20(String operation) {
168: return new ijException(LocalizedResource.getMessage(NotJDBC20,
169: operation));
170: }
171:
172: static ijException noUsingResults() {
173: return new ijException(LocalizedResource
174: .getMessage(NoUsingResults));
175: }
176:
177: static public ijException objectWasNull(String objectName) {
178: return new ijException(LocalizedResource.getMessage(
179: ObjectWasNull, objectName));
180: }
181:
182: static ijException resultSetGetWarningsFailed() {
183: return new ijException(LocalizedResource
184: .getMessage(ResultSetGetWarningsFailed));
185: }
186:
187: static ijException scrollCursorsNotSupported() {
188: return new ijException(LocalizedResource
189: .getMessage(ScrollCursorsNotSupported));
190: }
191:
192: //IJImpl20.utilMain can't throw exception for holdable cursors if
193: //following not declared public
194: public static ijException holdCursorsNotSupported() {
195: return new ijException(LocalizedResource
196: .getMessage(HoldCursorsNotSupported));
197: }
198:
199: static ijException statementGetWarningsFailed() {
200: return new ijException(LocalizedResource
201: .getMessage(StatementGetWarningsFailed));
202: }
203:
204: static ijException waitInterrupted(Throwable t) {
205: return new ijException(LocalizedResource.getMessage(
206: WaitInterrupted, t.toString()));
207: }
208:
209: public static ijException zeroInvalidForAbsolute() {
210: return new ijException(LocalizedResource
211: .getMessage(ZeroInvalidForAbsolute));
212: }
213: }
|