Example usage for java.sql SQLException getClass

List of usage examples for java.sql SQLException getClass

Introduction

In this page you can find the example usage for java.sql SQLException getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.openadaptor.util.JDBCUtil.java

public static void closeNoThrow(Statement s) {
    if (s != null) {
        try {/*from ww w .  j a v a  2 s .com*/
            s.close();
        } catch (SQLException e) {
            if (log.isDebugEnabled()) {
                log.debug("Ignoring exception " + e.getClass().getName() + " on close() -" + e.getMessage());
            }
        }
    }
}

From source file:org.openadaptor.util.JDBCUtil.java

public static void closeNoThrow(ResultSet rs) {
    if (rs != null) {
        try {/*from  ww  w . j  av  a  2s  . c o m*/
            rs.close();
        } catch (SQLException e) {
            if (log.isDebugEnabled()) {
                log.debug("Ignoring exception " + e.getClass().getName() + " on close() -" + e.getMessage());
            }
        }
    }
}

From source file:org.seasar.dbflute.logic.DfDBFluteTaskUtil.java

protected static void buildSQLExceptionMessage(ExceptionMessageBuilder br, SQLException e) {
    final String sqlState = DfJDBCException.extractSQLState(e);
    br.addItem("SQLState");
    br.addElement(sqlState);//from  ww w . ja  va 2  s  . c om
    final Integer errorCode = DfJDBCException.extractErrorCode(e);
    br.addItem("ErrorCode");
    br.addElement(errorCode);
    br.addItem("SQLException");
    br.addElement(e.getClass().getName());
    if (e instanceof DfJDBCException) {
        br.addElement("*Look at the message on the stack trace");
    } else {
        br.addElement(DfJDBCException.extractMessage(e));
    }
    final SQLException nextEx = e.getNextException();
    if (nextEx != null) {
        br.addItem("NextException");
        br.addElement(nextEx.getClass().getName());
        br.addElement(DfJDBCException.extractMessage(nextEx));
        final SQLException nextNextEx = nextEx.getNextException();
        if (nextNextEx != null) {
            br.addItem("NextNextException");
            br.addElement(nextNextEx.getClass().getName());
            br.addElement(DfJDBCException.extractMessage(nextNextEx));
        }
    }
}

From source file:com.xqdev.sql.MLSQL.java

private static void addExceptions(Element meta, SQLException e) {
    if (e == null)
        return;// ww w  .j ava  2  s.  co m

    Namespace sql = meta.getNamespace();
    Element exceptions = new Element("exceptions", sql);
    meta.addContent(exceptions);
    do {
        exceptions.addContent(new Element("exception", sql).setAttribute("type", e.getClass().getName())
                .addContent(new Element("reason", sql).setText(e.getMessage()))
                .addContent(new Element("sql-state", sql).setText(e.getSQLState()))
                .addContent(new Element("vendor-code", sql).setText("" + e.getErrorCode())));
        e = e.getNextException();
    } while (e != null);
}

From source file:org.seasar.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerExecute.java

protected void showContinueWarnLog(String sql, SQLException e) {
    final StringBuilder sb = new StringBuilder();
    sb.append("*Failure: ").append(e.getClass().getName()).append(ln());
    sb.append("/nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn");
    sb.append(ln());/*from  w  ww .jav a  2s .  c  o m*/
    sb.append(extractMessage(e)).append(ln());
    buildAdditionalErrorInfo(sb, e).append(ln());
    final SQLException nextEx = e.getNextException();
    if (nextEx != null) {
        sb.append("- - - - - - - - - -").append(ln());
        sb.append(extractMessage(nextEx)).append(ln());
        buildAdditionalErrorInfo(sb, nextEx).append(ln());
        final SQLException nextNextEx = nextEx.getNextException();
        if (nextNextEx != null) {
            sb.append("- - - - - - - - - -").append(ln());
            sb.append(extractMessage(nextNextEx)).append(ln());
            buildAdditionalErrorInfo(sb, nextNextEx).append(ln());
        }
    }
    sb.append("nnnnnnnnnnnnnnnnnnnn/");
    _log.warn(sb.toString());
}

From source file:com.clustercontrol.sql.util.AccessDB.java

/**
 * ??SQL??/*from ww  w. j a  va2  s .  c  o m*/
 *
 * @param sql SQL
 * @return
 * @throws SQLException
 */
public ResultSet read(String sql) throws SQLException {
    ResultSet result = null;
    try {
        result = m_statement.executeQuery(sql);

    } catch (SQLException e) {
        m_log.info("read() database query failure : url = " + m_url + ", " + e.getClass().getSimpleName() + ", "
                + e.getMessage());
        throw e;
    }
    return result;
}

From source file:com.poscoict.license.web.controller.ExceptionControllerAdvice.java

@ExceptionHandler(SQLException.class)
public ModelAndView handleSQLException(SQLException ex) {
    logger.error(ex.toString());//from ww  w .java2  s  .co  m
    ModelAndView mv = new ModelAndView(DEFAULT_ERROR_VIEW);
    mv.addObject("name", ex.getClass().getSimpleName());
    mv.addObject("message", "?? ? .  ? .");
    return mv;
}

From source file:com.clustercontrol.sql.util.AccessDB.java

/**
 * DB??/*w ww . j a  v a 2 s.  co m*/
 *
 */
public void terminate() {

    try {
        if (m_statement != null)
            m_statement.close();
    } catch (SQLException e) {
        m_log.info("terminate() database closing failure : url = " + m_url + ", " + e.getClass().getSimpleName()
                + ", " + e.getMessage());
    }

    try {
        if (m_connection != null)
            m_connection.close();
    } catch (SQLException e) {
        m_log.info("terminate() database closing failure : url = " + m_url + ", " + e.getClass().getSimpleName()
                + ", " + e.getMessage());
    }
}

From source file:org.fornax.cartridges.sculptor.framework.errorhandling.HibernateErrorHandlingAdvice.java

protected void handleDatabaseAccessException(Object target, Exception e) {
    Logger log = LoggerFactory.getLogger(target.getClass());

    // often the wrapped SQLException contains the interesting piece of
    // information
    StringBuilder message = new StringBuilder();
    message.append(e.getClass().getName()).append(": ");
    message.append(excMessage(e));//  w ww. j  a v  a 2 s  .c  o  m
    SQLException sqlExc = ExceptionHelper.unwrapSQLException(e);
    if (sqlExc != null) {
        message.append(", Caused by: ");
        message.append(sqlExc.getClass().getName()).append(": ");
        message.append(excMessage(sqlExc));
    }

    if (isJmsContext() && !isJmsRedelivered()) {
        LogMessage logMessage = new LogMessage(mapLogCode(DatabaseAccessException.ERROR_CODE),
                message.toString());
        log.info("{}", logMessage);
    } else {
        LogMessage logMmessage = new LogMessage(mapLogCode(DatabaseAccessException.ERROR_CODE),
                message.toString());
        log.error(logMmessage.toString(), e);
    }

    DatabaseAccessException newException = new DatabaseAccessException(message.toString());
    newException.setLogged(true);
    throw newException;
}

From source file:biopolis.headless.BiopolisManager.java

public WSResult<String> deleteIT(long pkgid) {
    try {/*from   w w  w  . j a  va  2s  .  com*/
        Long[] ids = { pkgid };
        this.delete(ids);
        return new WSResult<String>("OK");
    } catch (SQLException ex) {
        return new WSResult<String>(ex.getClass().getName(), ex.getMessage());
    }
}