/*
 * File   : $Source: /alkacon/cvs/opencms/src/org/opencms/db/CmsDbSqlException.java,v $
 * Date   : $Date: 2005/05/17 16:13:36 $
 * Version: $Revision: 1.2 $
 *
 * This library is part of OpenCms -
 * the Open Source Content Mananagement System
 *
 * Copyright (C) 2002 - 2005 Alkacon Software (http://www.alkacon.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * For further information about Alkacon Software, please see the
 * company website: http://www.alkacon.com
 *
 * For further information about OpenCms, please see the
 * project website: http://www.opencms.org
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package org.opencms.db;

import org.opencms.file.CmsDataAccessException;
import org.opencms.i18n.CmsMessageContainer;
import org.opencms.main.CmsException;

import java.sql.Statement;

import org.apache.commons.dbcp.DelegatingPreparedStatement;

/**
 * Used to signal sql related issues.<p> 
 * 
 * @author Michael Moossen (m.moossen@alkacon.com)
 * @version $Revision: 1.2 $
 * @since 5.7.3
 */
/**
 * Comment for <code>CmsDbSqlException</code>.<p>
 */
public class CmsDbSqlException extends CmsDataAccessException {

    /**
     * Creates a new localized Exception.<p>
     * 
     * @param container the localized message container to use
     */
    public CmsDbSqlException(CmsMessageContainer container) {

        super(container);
    }

    /**
     * Creates a new localized Exception that also containes a root cause.<p>
     * 
     * @param container the localized message container to use
     * @param cause the Exception root cause
     */
    public CmsDbSqlException(CmsMessageContainer container, Throwable cause) {

        super(container, cause);
    }   
    
    
    /**
     * @see org.opencms.main.CmsException#createException(org.opencms.i18n.CmsMessageContainer, java.lang.Throwable)
     */
    public CmsException createException(CmsMessageContainer container, Throwable cause) {
        
        return new CmsDbSqlException(container, cause);
    }   
    
    /**
     * Returns the query that let the statement crash.<p>
     * 
     * @param stmt the Statement to get the crashed query from
     * @return the crashed query
     */
    public static String getErrorQuery(Statement stmt) {

        if (stmt != null) {
            // unfortunately, DelegatingPreparedStatement has no toString() method implementation
            Statement s = stmt;
            while (s instanceof DelegatingPreparedStatement) {
                s = ((DelegatingPreparedStatement)s).getDelegate();
            }
            if (s != null) {
                // the query that crashed
                return s.toString();
            }
        } 
        return "";
    }    
}
@@ -116,18 +116,18 @@
 05/1
-7 16:13:36
+8 09:10:19
  $%0A 
@@ -146,25 +146,25 @@
 Revision: 1.
-2
+3
  $%0A *%0A * Thi
@@ -1303,56 +1303,8 @@
 b;%0A%0A
-import org.opencms.file.CmsDataAccessException;%0A
 impo
@@ -1598,17 +1598,17 @@
 sion: 1.
-2
+3
  $%0A * @s
@@ -1727,17 +1727,9 @@
 CmsD
-ataAccess
+b
 Exce

Extend CmsDbException