Package oracle.jdbc

Class OracleDatabaseException

  • All Implemented Interfaces:
    java.io.Serializable

    public class OracleDatabaseException
    extends java.lang.Exception
    Provides additional information about the Oracle error. Any information which is specific to the Oracle error may go into this class. In case of any parsing error while executing sql in Oracle server, an instance of this class is set as cause of the SQLException thrown by executeXXX methods in oracle.jdbc.Statement and its subclasses. For example, the error position in the failed SQL can be obtained as below,
      try{
        myStatement.executeUpdate();
      }
      catch (SQLException sqlx) {
        if(sqlx.getCause() != null &&
            sqlx.getCause() instanceof OracleDatabaseException) {
          int sqlErrorPosition = 
             ((OracleDatabaseException)sqlx.getCause()).getErrorPosition();
        }
      }
      
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      OracleDatabaseException​(int errorPosition, int oracleErrorNumber, java.lang.String oracleErrorMessage, java.lang.String sql, java.lang.String originalSql)  
      OracleDatabaseException​(int errorPosition, int oracleErrorNumber, java.lang.String oracleErrorMessage, java.lang.String sql, java.lang.String originalSql, boolean isSqlRewritten)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getErrorPosition()
      In case of a parsing error, this method returns the position of the error in the actual SQL which has failed in the server.
      int getOracleErrorNumber()
      Returns the Oracle error number for this failure.
      java.lang.String getOriginalSql()
      Returns the original SQL used to create the Statement.
      java.lang.String getSql()
      Returns the actual SQL which was sent to the server.
      boolean isSqlRewritten()
      Returns true if the executed SQL includes expressions that were added by the Oracle JDBC Driver, such as a ROWID in the SELECT clause, or a RETURNING ...
      java.lang.String toString()  
      • Methods inherited from class java.lang.Throwable

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

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

      • OracleDatabaseException

        public OracleDatabaseException​(int errorPosition,
                                       int oracleErrorNumber,
                                       java.lang.String oracleErrorMessage,
                                       java.lang.String sql,
                                       java.lang.String originalSql)
      • OracleDatabaseException

        public OracleDatabaseException​(int errorPosition,
                                       int oracleErrorNumber,
                                       java.lang.String oracleErrorMessage,
                                       java.lang.String sql,
                                       java.lang.String originalSql,
                                       boolean isSqlRewritten)
    • Method Detail

      • getErrorPosition

        public int getErrorPosition()
        In case of a parsing error, this method returns the position of the error in the actual SQL which has failed in the server. The position corresponds to the actual SQL sent to the server returned by getSql(). It may be different from the original SQL returned by getOriginalSql().
        Returns:
        errorPosition
      • getOracleErrorNumber

        public int getOracleErrorNumber()
        Returns the Oracle error number for this failure.
        Returns:
        OracleErrorNumber
      • getSql

        public java.lang.String getSql()
        Returns the actual SQL which was sent to the server.
        Returns:
        sql
      • getOriginalSql

        public java.lang.String getOriginalSql()
        Returns the original SQL used to create the Statement. This SQL may have been modified before being sent to the database to be executed. The SQL sent to the database is returned by getSql(). The method getErrorPosition() returns the position of the error in the actual SQL sent to the database, not the original SQL returned by this method.
        Returns:
        originalSql
      • isSqlRewritten

        public boolean isSqlRewritten()
        Returns true if the executed SQL includes expressions that were added by the Oracle JDBC Driver, such as a ROWID in the SELECT clause, or a RETURNING ... INTO ... clause for DML that returns generated values.
        Returns:
        true if the SQL was rewritten by the driver, otherwise returns false.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Throwable