001    package org.apache.ojb.broker;
002    
003    /* Copyright 2002-2005 The Apache Software Foundation
004     *
005     * Licensed under the Apache License, Version 2.0 (the "License");
006     * you may not use this file except in compliance with the License.
007     * You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    
018    import java.sql.SQLException;
019    
020    /**
021     * Encapsulates a SQL exception thrown during a broker action.
022     * 
023     * @author Thomas Mahler
024     * @version $Id: PersistenceBrokerSQLException.java,v 1.1 2007-08-24 22:17:35 ewestfal Exp $
025     */ 
026    public class PersistenceBrokerSQLException extends PersistenceBrokerException
027    {
028            private String sqlState = null;
029            
030        /**
031         * Creates a new exception instance.
032         */
033        public PersistenceBrokerSQLException()
034        {
035            super();
036        }
037    
038        /**
039         * Creates a new exception instance.
040         * 
041         * @param cause The base exception
042         */
043        public PersistenceBrokerSQLException(SQLException cause)
044        {
045            super(cause);
046            sqlState = cause.getSQLState();
047        }
048        
049        /**
050         * Creates a new exception instance.
051         * 
052         * @param msg The exception message
053         */
054        public PersistenceBrokerSQLException(String msg)
055        {
056            super(msg);
057        }
058    
059        /**
060         * Creates a new exception instance.
061         * 
062         * @param msg   The exception message
063         * @param cause The base exception
064         */
065        public PersistenceBrokerSQLException(String msg, SQLException cause)
066        {
067            super(msg, cause);
068            sqlState = cause.getSQLState();
069        }
070    
071        /**
072         * Returns the SQL state of the underlying {@link java.sql.SQLException}.
073         * 
074         * @return The SQL state
075         */
076        public String getSQLState()
077        {
078            return sqlState;
079        }
080    }