Class SqlException

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    SqlSkippedException

    public class SqlException
    extends java.lang.RuntimeException
    An exception that provides information on a database access error or other errors.

    Each SqlException provides several kinds of information:

    • a string describing the error. This is used as the Java Exception message, available via the method Throwable.getMessage().
    • a "SQLstate" string, which follows either the XOPEN SQLstate conventions or the SQL:2003 conventions. The values of the SQLState string are described in the appropriate spec.
    • an integer error code that is specific to each vendor. Normally this will be the actual error code returned by the underlying database.
    • the causal relationship, if any for this SqlException.
    • the SQL string that was executing when the error occurred. May be null.
    • the position in the SQL string where the error was detected.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      SqlException​(java.lang.String message, java.lang.Throwable cause, java.lang.String sqlState, int vendorCode, java.lang.String sql, int position)  
      SqlException​(java.lang.Throwable ex)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getPosition()
      Get the position.
      java.lang.String getSqlState()
      Retrieves the SqlState for this SqlException object.
      java.lang.String getSqlString()
      Get the sql.
      int getVendorCode()
      Retrieves the vendor-specific exception code for this SqlException object.
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • SqlException

        public SqlException​(java.lang.Throwable ex)
      • SqlException

        public SqlException​(java.lang.String message,
                            java.lang.Throwable cause,
                            java.lang.String sqlState,
                            int vendorCode,
                            java.lang.String sql,
                            int position)
        Parameters:
        message -
        cause -
        sqlState -
        vendorCode -
        sql -
        position -
    • Method Detail

      • getSqlState

        public java.lang.String getSqlState()
        Retrieves the SqlState for this SqlException object.
        Returns:
        the SQLState value
      • getVendorCode

        public int getVendorCode()
        Retrieves the vendor-specific exception code for this SqlException object.
        Returns:
        the vendor's error code
      • getPosition

        public int getPosition()
        Get the position.
        Returns:
        the index of the first character in sql where an error is detected. Zero based. -1 if the position is not defined or unknown.
      • getSqlString

        public java.lang.String getSqlString()
        Get the sql.
        Returns:
        the SQL string sent to the database. May be null.