001/*
002 * Copyright 2002-2012 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.jdbc;
018
019import java.sql.SQLWarning;
020
021import org.springframework.dao.UncategorizedDataAccessException;
022
023/**
024 * Exception thrown when we're not ignoring {@link java.sql.SQLWarning SQLWarnings}.
025 *
026 * <p>If a SQLWarning is reported, the operation completed, so we will need
027 * to explicitly roll it back if we're not happy when looking at the warning.
028 * We might choose to ignore (and log) the warning, or to wrap and throw it
029 * in the shape of this SQLWarningException instead.
030 *
031 * @author Rod Johnson
032 * @author Juergen Hoeller
033 * @see org.springframework.jdbc.core.JdbcTemplate#setIgnoreWarnings
034 */
035@SuppressWarnings("serial")
036public class SQLWarningException extends UncategorizedDataAccessException {
037
038        /**
039         * Constructor for SQLWarningException.
040         * @param msg the detail message
041         * @param ex the JDBC warning
042         */
043        public SQLWarningException(String msg, SQLWarning ex) {
044                super(msg, ex);
045        }
046
047        /**
048         * Return the underlying SQLWarning.
049         */
050        public SQLWarning SQLWarning() {
051                return (SQLWarning) getCause();
052        }
053
054}