KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > jdbc > IncorrectResultSetColumnCountException


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 DataRetrievalFailureException {
30
31     private int expectedCount;
32
33     private int actualCount;
34
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, int actualCount) {
42         super("Incorrect column count: expected " + expectedCount + ", actual " + actualCount);
43         this.expectedCount = expectedCount;
44         this.actualCount = actualCount;
45     }
46
47     /**
48      * Constructor for IncorrectResultCountDataAccessException.
49      * @param msg the detail message
50      * @param expectedCount the expected column count
51      * @param actualCount the actual column count
52      */

53     public IncorrectResultSetColumnCountException(String JavaDoc msg, int expectedCount, int actualCount) {
54         super(msg);
55         this.expectedCount = expectedCount;
56         this.actualCount = actualCount;
57     }
58
59
60     /**
61      * Return the expected column count.
62      */

63     public int getExpectedCount() {
64         return expectedCount;
65     }
66
67     /**
68      * Return the actual column count.
69      */

70     public int getActualCount() {
71         return actualCount;
72     }
73
74 }
75
Popular Tags