Package oracle.jdbc
Class OracleDatabaseException
java.lang.Object
java.lang.Throwable
java.lang.Exception
oracle.jdbc.OracleDatabaseException
- All Implemented Interfaces:
Serializable
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:
-
Constructor Summary
ConstructorsConstructorDescriptionOracleDatabaseException(int errorPosition, int oracleErrorNumber, String oracleErrorMessage, String sql, String originalSql) OracleDatabaseException(int errorPosition, int oracleErrorNumber, String oracleErrorMessage, String sql, String originalSql, boolean isSqlRewritten) -
Method Summary
Modifier and TypeMethodDescriptionintIn case of a parsing error, this method returns the position of the error in the actual SQL which has failed in the server.intReturns the Oracle error number for this failure.Returns the original SQL used to create the Statement.getSql()Returns the actual SQL which was sent to the server.booleanReturnstrueif the executed SQL includes expressions that were added by the Oracle JDBC Driver, such as aROWIDin the SELECT clause, or aRETURNING ...toString()Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Constructor Details
-
OracleDatabaseException
-
OracleDatabaseException
-
-
Method Details
-
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 bygetSql(). It may be different from the original SQL returned bygetOriginalSql().- Returns:
- errorPosition
-
getOracleErrorNumber
public int getOracleErrorNumber()Returns the Oracle error number for this failure.- Returns:
- OracleErrorNumber
-
getSql
Returns the actual SQL which was sent to the server.- Returns:
- sql
-
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 bygetSql(). The methodgetErrorPosition()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()Returnstrueif the executed SQL includes expressions that were added by the Oracle JDBC Driver, such as aROWIDin the SELECT clause, or aRETURNING ... INTO ...clause for DML that returns generated values.- Returns:
trueif the SQL was rewritten by the driver, otherwise returnsfalse.
-
toString
-