Example usage for javax.sql.rowset.spi SyncProviderException getLocalizedMessage

List of usage examples for javax.sql.rowset.spi SyncProviderException getLocalizedMessage

Introduction

In this page you can find the example usage for javax.sql.rowset.spi SyncProviderException getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:com.egt.core.db.xdp.RecursoCachedRowSet.java

/**
 * {@inheritDoc}/*from   w  ww  .j a va2s .  c om*/
 */
@Override
public void acceptChanges() throws SyncProviderException {
    try {
        this.getFilasConflictivas().clear();
        super.acceptChanges();
    } catch (SyncProviderException spe) {
        SyncResolver resolver = spe.getSyncResolver();
        if (resolver != null && resolver instanceof SyncResolverX) {
            boolean showDeleted = this.tryToGetShowDeleted();
            boolean sinDuplicados = TLC.getBitacora().isSinDuplicados();
            int conflictos = 0;
            int row;
            int status = SyncResolver.NO_ROW_CONFLICT;
            String transaction = DBUtils.getTransactionLabel(status);
            SQLException sqlException;
            int errorCode;
            String message;
            String localizedMessage;
            String sqlState;
            String heading;
            String clave = CBM2.COMMIT_CHANGES_UNKNOWN_EXCEPTION;
            int tipoError; /* OJO con la constante, 1 -> fila con un error desconocido */
            String mensaje;
            String prefijo = Global.PREFIJO_ETIQUETA_ID_RECURSO;
            try {
                this.tryToSetShowDeleted(true);
                TLC.getBitacora().setSinDuplicados(true);
                while (resolver.nextConflict()) {
                    conflictos++;
                    row = resolver.getRow();
                    status = resolver.getStatus();
                    transaction = DBUtils.getTransactionLabel(status);
                    sqlException = ((SyncResolverX) resolver).getSQLException();
                    errorCode = sqlException.getErrorCode();
                    message = sqlException.getMessage();
                    localizedMessage = StringUtils.substringBefore(sqlException.getLocalizedMessage(),
                            " Where: ");
                    sqlState = sqlException.getSQLState();
                    heading = "Row:" + row + ", Status:" + status + ", Code:" + errorCode + ", State:"
                            + sqlState;
                    Bitacora.trace(heading + message);
                    if (TLC.getInterpreteSql().isCommandIgnoredException(sqlException)) {
                        clave = CBM2.COMMIT_CHANGES_COMMAND_IGNORED_EXCEPTION;
                        tipoError = 0; /* OJO con la constante, 0 -> fila "ignorada" (no se sabe si tiene o no errores) */
                        mensaje = tipoError + Bitacora.getTextoMensaje(clave, transaction, prefijo + row);
                        TLC.getBitacora().error(CBM2.COMMIT_CHANGES_COMMAND_IGNORED);
                        if (status == SyncResolver.DELETE_ROW_CONFLICT) {
                            this.tryToSetShowDeleted(false);
                        }
                    } else {
                        String columna = TLC.getInterpreteSql()
                                .getNotNullConstraintViolationColumn(sqlException);
                        if (StringUtils.isNotBlank(columna)) {
                            clave = CBM2.DATABASE_NOT_NULL_CONSTRAINT_VIOLATION;
                            tipoError = 2; /* OJO con la constante, 2 -> fila con un error conocido */
                            mensaje = tipoError
                                    + TLC.getBitacora().error(clave, transaction, prefijo + row, columna);
                        } else {
                            clave = DBUtils.getConstraintMessageKey(message, status);
                            if (clave == null) {
                                clave = CBM2.COMMIT_CHANGES_UNKNOWN_EXCEPTION;
                                tipoError = 1; /* OJO con la constante, 1 -> fila con un error desconocido */
                                mensaje = tipoError + TLC.getBitacora().error(clave, transaction, prefijo + row,
                                        localizedMessage);
                            } else {
                                tipoError = 2; /* OJO con la constante, 2 -> fila con un error conocido */
                                mensaje = tipoError
                                        + TLC.getBitacora().error(clave, transaction, prefijo + row);
                            }
                        }
                    }
                    this.getFilasConflictivas().put(String.valueOf(row - 1), mensaje);
                    //                      if (status == SyncResolver.DELETE_ROW_CONFLICT)
                    //                          if (this.absolute(row))
                    //                              if (this.rowDeleted()) // RETORNA FALSO!
                    //                                  this.undoDelete();
                }
                if (conflictos == 0) { /* esto parece un BUG, y pasa cuando se elimina la ultima fila y showDeleted==false */
                    TLC.getBitacora().error(clave, transaction, "", spe.getLocalizedMessage());
                }
            } catch (SQLException ex) {
                TLC.getBitacora().fatal(ex);
            } finally {
                this.tryToSetShowDeleted(showDeleted);
                TLC.getBitacora().setSinDuplicados(sinDuplicados);
                throw new SyncProviderException(this.getSyncProviderExceptionString(spe));
            }
        }
        throw spe;
    }
}

From source file:ips1ap101.lib.core.db.xdp.RecursoCachedRowSet.java

/**
 * {@inheritDoc}/*from   ww  w . ja v  a 2 s .c o m*/
 */
@Override
public void acceptChanges() throws SyncProviderException {
    try {
        this.getFilasConflictivas().clear();
        super.acceptChanges();
    } catch (SyncProviderException spe) {
        SyncResolver resolver = spe.getSyncResolver();
        if (resolver != null && resolver instanceof SyncResolverX) {
            boolean showDeleted = this.tryToGetShowDeleted();
            boolean sinDuplicados = TLC.getBitacora().isSinDuplicados();
            int conflictos = 0;
            int row;
            int status = SyncResolver.NO_ROW_CONFLICT;
            String transaction = DBUtils.getTransactionLabel(status);
            SQLException sqlException;
            int errorCode;
            String message;
            String localizedMessage;
            String sqlState;
            String clave = CBM.COMMIT_CHANGES_UNKNOWN_EXCEPTION;
            int tipoError; /* OJO con la constante, 1 -> fila con un error desconocido */
            String mensaje;
            String prefijo = Global.PREFIJO_ETIQUETA_ID_RECURSO;
            try {
                this.tryToSetShowDeleted(true);
                TLC.getBitacora().setSinDuplicados(true);
                while (resolver.nextConflict()) {
                    conflictos++;
                    row = resolver.getRow();
                    status = resolver.getStatus();
                    transaction = DBUtils.getTransactionLabel(status);
                    sqlException = ((SyncResolverX) resolver).getSQLException();
                    errorCode = sqlException.getErrorCode();
                    message = sqlException.getMessage();
                    localizedMessage = DBUtils.getProperErrorMessage(sqlException.getLocalizedMessage());
                    sqlState = sqlException.getSQLState();
                    Bitacora.trace("SQLException Message = " + message);
                    Bitacora.trace("SQLException Localized Message = " + localizedMessage);
                    Bitacora.trace("SQLException Row = " + row + ", Status = " + status + ", Code = "
                            + errorCode + ", State = " + sqlState);
                    if (TLC.getInterpreteSql().isCommandIgnoredException(sqlException)) {
                        clave = CBM.COMMIT_CHANGES_COMMAND_IGNORED_EXCEPTION;
                        tipoError = 0; /* OJO con la constante, 0 -> fila "ignorada" (no se sabe si tiene o no errores) */
                        mensaje = tipoError + Bitacora.getTextoMensaje(clave, transaction, prefijo + row);
                        TLC.getBitacora().error(CBM.COMMIT_CHANGES_COMMAND_IGNORED);
                        if (status == SyncResolver.DELETE_ROW_CONFLICT) {
                            this.tryToSetShowDeleted(false);
                        }
                    } else {
                        String columna = TLC.getInterpreteSql()
                                .getNotNullConstraintViolationColumn(sqlException);
                        if (StringUtils.isNotBlank(columna)) {
                            clave = CBM.DATABASE_NOT_NULL_CONSTRAINT_VIOLATION;
                            tipoError = 2; /* OJO con la constante, 2 -> fila con un error conocido */
                            mensaje = tipoError
                                    + TLC.getBitacora().error(clave, transaction, prefijo + row, columna);
                        } else {
                            clave = DBUtils.getConstraintMessageKey(message, status);
                            if (clave == null) {
                                clave = CBM.COMMIT_CHANGES_UNKNOWN_EXCEPTION;
                                tipoError = 1; /* OJO con la constante, 1 -> fila con un error desconocido */
                                mensaje = tipoError + TLC.getBitacora().error(clave, transaction, prefijo + row,
                                        localizedMessage);
                            } else {
                                tipoError = 2; /* OJO con la constante, 2 -> fila con un error conocido */
                                mensaje = tipoError
                                        + TLC.getBitacora().error(clave, transaction, prefijo + row);
                            }
                        }
                    }
                    this.getFilasConflictivas().put(String.valueOf(row - 1), mensaje);
                    //                      if (status == SyncResolver.DELETE_ROW_CONFLICT)
                    //                          if (this.absolute(row))
                    //                              if (this.rowDeleted()) // RETORNA FALSO!
                    //                                  this.undoDelete();
                }
                if (conflictos == 0) { /* esto parece un BUG, y pasa cuando se elimina la ultima fila y showDeleted==false */
                    TLC.getBitacora().error(clave, transaction, "", spe.getLocalizedMessage());
                }
            } catch (SQLException ex) {
                TLC.getBitacora().fatal(ex);
            } finally {
                this.tryToSetShowDeleted(showDeleted);
                TLC.getBitacora().setSinDuplicados(sinDuplicados);
                throw new SyncProviderException(this.getSyncProviderExceptionString(spe));
            }
        }
        throw spe;
    }
}