Java SQLException mergeSQLExceptionMsg(final StringBuilder msgBuilder, final SQLException e, final String prefix)

Here you can find the source of mergeSQLExceptionMsg(final StringBuilder msgBuilder, final SQLException e, final String prefix)

Description

merge SQL Exception Msg

License

Open Source License

Parameter

Parameter Description
msgBuilder message builder
e exception
prefix space prefix for each line.

Declaration

private static void mergeSQLExceptionMsg(final StringBuilder msgBuilder, final SQLException e,
        final String prefix) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.sql.SQLException;

public class Main {
    /**/*www.j  a v  a  2s . c  o  m*/
     * @param msgBuilder message builder
     * @param e exception
     * @param prefix space prefix for each line.
     * */
    private static void mergeSQLExceptionMsg(final StringBuilder msgBuilder, final SQLException e,
            final String prefix) {
        msgBuilder.append(prefix + "ErrorCode: ");
        msgBuilder.append(e.getErrorCode());
        msgBuilder.append(", SQLState: ");
        msgBuilder.append(e.getSQLState());
        msgBuilder.append(", Msg: ");
        String m = e.getMessage();
        if (m != null) {
            msgBuilder.append(prefix + m.replaceAll("\n", "\n" + prefix));
        }
        if (e.getNextException() != null) {
            msgBuilder.append("\n");
            mergeSQLExceptionMsg(msgBuilder, e.getNextException(), prefix + "  ");
        }
    }
}

Related

  1. log(SQLException e, Logger log)
  2. logAll(Log log, SQLException e)
  3. logSqlError(SQLException ex, Logger logger)
  4. mergeException(List exceptions)
  5. mergeException(List exceptions)
  6. oracleSessionHasBeenKilled(Exception exception)
  7. parseRemoteException(Throwable t)
  8. printExceptionAndRollback(Connection conn, Exception e)
  9. printExceptions(OutputStream os, SQLException sqlEx)