KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > jdbc > support > SQLExceptionTranslator


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.support;
18
19 import java.sql.SQLException JavaDoc;
20
21 import org.springframework.dao.DataAccessException;
22
23 /**
24  * Strategy interface for translating between {@link SQLException SQLExceptions}
25  * and Spring's data access strategy-agnostic {@link DataAccessException}
26  * hierarchy.
27  *
28  * <p>Implementations can be generic (for example, using
29  * {@link java.sql.SQLException#getSQLState() SQLState} codes for JDBC) or wholly
30  * proprietary (for example, using Oracle error codes) for greater precision.
31  *
32  * @author Rod Johnson
33  * @see org.springframework.dao.DataAccessException
34  */

35 public interface SQLExceptionTranslator {
36
37     /**
38      * Translate the given {@link SQLException} into a generic {@link DataAccessException}.
39      * @param task readable text describing the task being attempted
40      * @param sql SQL query or update that caused the problem. May be <code>null</code>.
41      * @param ex the offending <code>SQLException</code>
42      * @return the DataAccessException to throw
43      */

44     DataAccessException translate(String JavaDoc task, String JavaDoc sql, SQLException JavaDoc ex);
45
46 }
47
Popular Tags