Java SQLException extractErrorCode(SQLException sqlException)

Here you can find the source of extractErrorCode(SQLException sqlException)

Description

For the given SQLException, locates the vendor-specific error code.

License

Apache License

Parameter

Parameter Description
sqlException The exception from which to extract the SQLState

Return

The error code.

Declaration

public static int extractErrorCode(SQLException sqlException) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.sql.SQLException;

public class Main {
    /**/*from   ww w  . j  a v  a  2  s  . co m*/
     * For the given SQLException, locates the vendor-specific error code.
     * 
     * @param sqlException
     *            The exception from which to extract the SQLState
     * @return The error code.
     */
    public static int extractErrorCode(SQLException sqlException) {
        int errorCode = sqlException.getErrorCode();
        SQLException nested = sqlException.getNextException();
        while (errorCode == 0 && nested != null) {
            errorCode = nested.getErrorCode();
            nested = nested.getNextException();
        }
        return errorCode;
    }
}

Related

  1. convertSQLExceptionToString(SQLException e)
  2. createFeatureNotSupportedException()
  3. exceptionMsg2LocalizedStr(final Throwable e)
  4. exceptionMsg2str(final Throwable e)
  5. exceptionToString(Throwable e)
  6. extractNestedSQLExceptions( SQLException exception)
  7. extractSqlStateClassCode(SQLException sqlException)
  8. getAllMessages(Throwable t, boolean includeExceptionName)
  9. getAllMessagesArray(Throwable t, boolean includeExceptionName)