Package org.hibernate

Class JDBCException

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ConstraintViolationException, DataException, GenericJDBCException, JDBCConnectionException, LockAcquisitionException, PessimisticLockException, QueryTimeoutException, SQLGrammarException

public class JDBCException extends HibernateException
Wraps a SQLException arising from the JDBC driver. Indicates that an error occurred during a JDBC call.
See Also:
  • Constructor Details

    • JDBCException

      public JDBCException(String message, SQLException cause)
      Constructs a JDBCException using the given information.
      Parameters:
      message - The message explaining the exception condition
      cause - The underlying cause
    • JDBCException

      public JDBCException(String message, SQLException cause, String sql)
      Constructs a JDBCException using the given information.
      Parameters:
      message - The message explaining the exception condition
      cause - The underlying cause
      sql - The sql being executed when the exception occurred
  • Method Details

    • getSQLState

      public String getSQLState()
      Get the X/Open or ANSI SQL SQLState error code from the underlying SQLException.
      Returns:
      The X/Open or ANSI SQL SQLState error code; may return null.
      See Also:
    • getErrorCode

      public int getErrorCode()
      Get the vendor specific error code from the underlying SQLException.
      Returns:
      The vendor specific error code
      See Also:
    • getSQLException

      public SQLException getSQLException()
      Get the underlying SQLException.
      Returns:
      The SQLException
    • getSQL

      public String getSQL()
      Get the actual SQL statement being executed when the exception occurred.
      Returns:
      The SQL statement; may return null.
    • getErrorMessage

      public String getErrorMessage()
      Returns:
      The error message without the SQL statement appended