/*
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * Copyright (c) 2008, 2013, Red Hat Inc. or third-party contributors as
 * indicated by the @author tags or express copyright attribution
 * statements applied by the authors.  All third-party contributions are
 * distributed under license by Red Hat Inc.
 *
 * This copyrighted material is made available to anyone wishing to use, modify,
 * copy, or redistribute it subject to the terms and conditions of the GNU
 * Lesser General Public License, as published by the Free Software Foundation.
 *
 * This program 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.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this distribution; if not, write to:
 * Free Software Foundation, Inc.
 * 51 Franklin Street, Fifth Floor
 * Boston, MA  02110-1301  USA
 */
package org.hibernate;

import java.sql.SQLException;

Wraps a SQLException. Indicates that an exception occurred during a JDBC call.
Author:Gavin King
See Also:
/** * Wraps a {@link SQLException}. Indicates that an exception occurred during a JDBC call. * * @author Gavin King * * @see java.sql.SQLException */
public class JDBCException extends HibernateException { private final SQLException sqlException; private final String sql;
Constructs a JDBCException using the given information.
Params:
  • message – The message explaining the exception condition
  • cause – The underlying cause
/** * Constructs a JDBCException using the given information. * * @param message The message explaining the exception condition * @param cause The underlying cause */
public JDBCException(String message, SQLException cause) { this( message, cause, null ); }
Constructs a JDBCException using the given information.
Params:
  • message – The message explaining the exception condition
  • cause – The underlying cause
  • sql – The sql being executed when the exception occurred
/** * Constructs a JDBCException using the given information. * * @param message The message explaining the exception condition * @param cause The underlying cause * @param sql The sql being executed when the exception occurred */
public JDBCException(String message, SQLException cause, String sql) { super( message, cause ); this.sqlException = cause; this.sql = sql; }
Get the X/Open or ANSI SQL SQLState error code from the underlying SQLException.
See Also:
Returns:The X/Open or ANSI SQL SQLState error code; may return null.
/** * Get the X/Open or ANSI SQL SQLState error code from the underlying {@link SQLException}. * * @return The X/Open or ANSI SQL SQLState error code; may return null. * * @see java.sql.SQLException#getSQLState() */
public String getSQLState() { return sqlException.getSQLState(); }
Get the vendor specific error code from the underlying SQLException.
See Also:
Returns:The vendor specific error code
/** * Get the vendor specific error code from the underlying {@link SQLException}. * * @return The vendor specific error code * * @see java.sql.SQLException#getErrorCode() */
public int getErrorCode() { return sqlException.getErrorCode(); }
Get the underlying SQLException.
Returns:The SQLException
/** * Get the underlying {@link SQLException}. * * @return The SQLException */
public SQLException getSQLException() { return sqlException; }
Get the actual SQL statement being executed when the exception occurred.
Returns:The SQL statement; may return null.
/** * Get the actual SQL statement being executed when the exception occurred. * * @return The SQL statement; may return null. */
public String getSQL() { return sql; } }