01: /*
02: * Copyright 2002-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.jdbc;
18:
19: import org.springframework.dao.DataRetrievalFailureException;
20:
21: /**
22: * Data access exception thrown when a result set did not have the correct column count,
23: * for example when expecting a single column but getting 0 or more than 1 columns.
24: *
25: * @author Juergen Hoeller
26: * @since 2.0
27: * @see org.springframework.dao.IncorrectResultSizeDataAccessException
28: */
29: public class IncorrectResultSetColumnCountException extends
30: DataRetrievalFailureException {
31:
32: private int expectedCount;
33:
34: private int actualCount;
35:
36: /**
37: * Constructor for IncorrectResultSetColumnCountException.
38: * @param expectedCount the expected column count
39: * @param actualCount the actual column count
40: */
41: public IncorrectResultSetColumnCountException(int expectedCount,
42: int actualCount) {
43: super ("Incorrect column count: expected " + expectedCount
44: + ", actual " + actualCount);
45: this .expectedCount = expectedCount;
46: this .actualCount = actualCount;
47: }
48:
49: /**
50: * Constructor for IncorrectResultCountDataAccessException.
51: * @param msg the detail message
52: * @param expectedCount the expected column count
53: * @param actualCount the actual column count
54: */
55: public IncorrectResultSetColumnCountException(String msg,
56: int expectedCount, int actualCount) {
57: super (msg);
58: this .expectedCount = expectedCount;
59: this .actualCount = actualCount;
60: }
61:
62: /**
63: * Return the expected column count.
64: */
65: public int getExpectedCount() {
66: return expectedCount;
67: }
68:
69: /**
70: * Return the actual column count.
71: */
72: public int getActualCount() {
73: return actualCount;
74: }
75:
76: }
|