/** * Get the error code. * * @return the error code */ public int getErrorCode() { return getSQLException().getErrorCode(); }
/** * INTERNAL */ static SQLException getUnsupportedException() { return DbException.get(ErrorCode.FEATURE_NOT_SUPPORTED_1). getSQLException(); }
/** * Throw a SQLException saying this command line option is not supported. * * @param option the unsupported option * @return this method never returns normally */ protected SQLException throwUnsupportedOption(String option) throws SQLException { throw DbException.get( ErrorCode.FEATURE_NOT_SUPPORTED_1, option).getSQLException(); }
/** * Convert an exception to a SQL exception using the default mapping. * * @param e the root cause * @return the SQL exception object */ public static SQLException toSQLException(Throwable e) { if (e instanceof SQLException) { return (SQLException) e; } return convert(e).getSQLException(); }
private void checkColumnIndex(int columnIndex) throws SQLException { if (columnIndex < 1 || columnIndex > columns.size()) { throw DbException.getInvalidValueException( "columnIndex", columnIndex).getSQLException(); } }
private static SQLException convertException(String message, Exception e) { return DbException.get(ErrorCode.IO_EXCEPTION_1, e, message).getSQLException(); }
private Object get(int columnIndex) throws SQLException { if (currentRow == null) { throw DbException.get(ErrorCode.NO_DATA_AVAILABLE). getSQLException(); } checkColumnIndex(columnIndex); columnIndex--; Object o = columnIndex < currentRow.length ? currentRow[columnIndex] : null; wasNull = o == null; return o; }
/** * Searches for a specific column in the result set. A case-insensitive * search is made. * * @param columnLabel the column label * @return the column index (1,2,...) * @throws SQLException if the column is not found or if the result set is * closed */ @Override public int findColumn(String columnLabel) throws SQLException { if (columnLabel != null && columns != null) { for (int i = 0, size = columns.size(); i < size; i++) { if (columnLabel.equalsIgnoreCase(getColumn(i).name)) { return i + 1; } } } throw DbException.get(ErrorCode.COLUMN_NOT_FOUND_1, columnLabel) .getSQLException(); }
/** * Set the SQL statement of the given exception. * This method may create a new object. * * @param sql the SQL statement * @return the exception */ public DbException addSQL(String sql) { SQLException e = getSQLException(); if (e instanceof JdbcSQLException) { JdbcSQLException j = (JdbcSQLException) e; if (j.getSQL() == null) { j.setSQL(sql); } return this; } e = new JdbcSQLException(e.getMessage(), sql, e.getSQLState(), e.getErrorCode(), e, null); return new DbException(e); }
if (!rs.next()) { throw DbException.get(ErrorCode.IO_EXCEPTION_1, "Missing lob entry: " + lobId).getSQLException(); if (lobMapCount == 0) { throw DbException.get(ErrorCode.IO_EXCEPTION_1, "Missing lob entry: " + lobId).getSQLException();
throw DbException.get(ErrorCode.IO_EXCEPTION_1, "Missing lob entry, block: " + block) .getSQLException();
throw DbException.get( ErrorCode.CANNOT_CHANGE_SETTING_WHEN_OPEN_1, message).getSQLException(); throw DbException.get( ErrorCode.CANNOT_CHANGE_SETTING_WHEN_OPEN_1, e, message).getSQLException();
int errorCode = 0; if (e instanceof DbException) { e = ((DbException) e).getSQLException(); errorCode = ((SQLException) e).getErrorCode();
private void sendError(Throwable t) { try { SQLException e = DbException.convert(t).getSQLException(); StringWriter writer = new StringWriter(); e.printStackTrace(new PrintWriter(writer)); String trace = writer.toString(); String message; String sql; if (e instanceof JdbcSQLException) { JdbcSQLException j = (JdbcSQLException) e; message = j.getOriginalMessage(); sql = j.getSQL(); } else { message = e.getMessage(); sql = null; } transfer.writeInt(SessionRemote.STATUS_ERROR). writeString(e.getSQLState()).writeString(message). writeString(sql).writeInt(e.getErrorCode()).writeString(trace).flush(); } catch (Exception e2) { if (!transfer.isClosed()) { server.traceError(e2); } // if writing the error does not work, close the connection stop = true; } }
/** * Execute the meta data statement. * * @param db the database * @param systemSession the system session * @param listener the database event listener */ void execute(Database db, Session systemSession, DatabaseEventListener listener) { try { Prepared command = systemSession.prepare(sql); command.setObjectId(id); command.update(); } catch (DbException e) { e = e.addSQL(sql); SQLException s = e.getSQLException(); db.getTrace(Trace.DATABASE).error(s, sql); if (listener != null) { listener.exceptionThrown(s, sql); // continue startup in this case } else { throw e; } } }
if (e.getErrorCode() == ErrorCode.DATABASE_ALREADY_OPEN_1) { if (autoServerMode) { String serverKey = ((JdbcSQLException) e.getSQLException()). getSQL(); if (serverKey != null) {
} catch (DbException e) { if (session.getDatabase().getLockMode() == Constants.LOCK_MODE_OFF && e.getSQLException().getErrorCode() == ErrorCode.DUPLICATE_KEY_1) {
SQLException s = e.getSQLException(); database.exceptionThrown(s, sql); if (s.getErrorCode() == ErrorCode.OUT_OF_MEMORY) {
SQLException s = e.getSQLException(); database.exceptionThrown(s, sql); if (s.getErrorCode() == ErrorCode.OUT_OF_MEMORY) {
/** * INTERNAL */ static SQLException getUnsupportedException() { return DbException.get(ErrorCode.FEATURE_NOT_SUPPORTED_1). getSQLException(); }