KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Copyright 2002-2005 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 java.sql.SQLException JavaDoc;
20
21 import org.springframework.dao.InvalidDataAccessResourceUsageException;
22
23 /**
24  * Exception thrown when a ResultSet has been accessed in an invalid fashion.
25  * Such exceptions always have a <code>java.sql.SQLException</code> root cause.
26  *
27  * <p>This typically happens when an invalid ResultSet column index or name
28  * has been specified. Also thrown by disconnected SqlRowSets.
29  *
30  * @author Juergen Hoeller
31  * @since 1.2
32  * @see BadSqlGrammarException
33  * @see org.springframework.jdbc.support.rowset.SqlRowSet
34  */

35 public class InvalidResultSetAccessException extends InvalidDataAccessResourceUsageException {
36     
37     private String JavaDoc sql;
38
39
40     /**
41      * Constructor for InvalidResultSetAccessException.
42      * @param task name of current task
43      * @param sql the offending SQL statement
44      * @param ex the root cause
45      */

46     public InvalidResultSetAccessException(String JavaDoc task, String JavaDoc sql, SQLException JavaDoc ex) {
47         super(task + "; invalid ResultSet access for SQL [" + sql + "]", ex);
48         this.sql = sql;
49     }
50     
51     /**
52      * Constructor for InvalidResultSetAccessException.
53      * @param ex the root cause
54      */

55     public InvalidResultSetAccessException(SQLException JavaDoc ex) {
56         super(ex.getMessage(), ex);
57     }
58
59
60     /**
61      * Return the wrapped SQLException.
62      */

63     public SQLException JavaDoc getSQLException() {
64         return (SQLException JavaDoc) getCause();
65     }
66
67     /**
68      * Return the SQL that caused the problem.
69      * @return the offending SQL, if known
70      */

71     public String JavaDoc getSql() {
72         return sql;
73     }
74
75 }
76
Popular Tags