/** * Check if this user has admin rights. An exception is thrown if he does * not have them. * * @throws DbException if this user is not an admin */ public void checkAdmin() { if (!admin) { throw DbException.get(ErrorCode.ADMIN_RIGHTS_REQUIRED); } }
/** * INTERNAL */ static SQLException getUnsupportedException() { return DbException.get(ErrorCode.FEATURE_NOT_SUPPORTED_1). getSQLException(); }
/** * Create a database exception for a specific error code. * * @param errorCode the error code * @param p1 the first parameter of the message * @return the exception */ public static DbException get(int errorCode, String p1) { return get(errorCode, new String[] { p1 }); }
private static JdbcSavepoint convertSavepoint(Savepoint savepoint) { if (!(savepoint instanceof JdbcSavepoint)) { throw DbException.get(ErrorCode.SAVEPOINT_IS_INVALID_1, "" + savepoint); } return (JdbcSavepoint) savepoint; }
private void checkCommitRollback() { if (commitOrRollbackDisabled && !locks.isEmpty()) { throw DbException.get(ErrorCode.COMMIT_ROLLBACK_NOT_ALLOWED); } }
/** * Gets a SQL exception meaning this value is invalid. * * @param param the name of the parameter * @param value the value passed * @return the IllegalArgumentException object */ public static DbException getInvalidValueException(String param, Object value) { return get(ErrorCode.INVALID_VALUE_2, value == null ? "null" : value.toString(), param); }
private void logWritingError(Exception e) { if (writingErrorLogged) { return; } writingErrorLogged = true; Exception se = DbException.get( ErrorCode.TRACE_FILE_ERROR_2, e, fileName, e.toString()); // print this error only once fileName = null; sysOut.println(se); se.printStackTrace(); }
private ValueDecimal(BigDecimal value) { if (value == null) { throw new IllegalArgumentException("null"); } else if (!value.getClass().equals(BigDecimal.class)) { throw DbException.get(ErrorCode.INVALID_CLASS_2, BigDecimal.class.getName(), value.getClass().getName()); } this.value = value; }
private void checkOnValidRow() { if (!isOnValidRow()) { throw DbException.get(ErrorCode.NO_DATA_AVAILABLE); } }
@Override public boolean needRebuild() { try { return dataMap.sizeAsLongMax() == 0; } catch (IllegalStateException e) { throw DbException.get(ErrorCode.OBJECT_CLOSED, e); } }
@Override public boolean needRebuild() { try { return dataMap.sizeAsLongMax() == 0; } catch (IllegalStateException e) { throw DbException.get(ErrorCode.OBJECT_CLOSED, e); } }
/** * Create a syntax error exception. * * @param sql the SQL statement * @param index the position of the error in the SQL statement * @return the exception */ public static DbException getSyntaxError(String sql, int index) { sql = StringUtils.addAsterisk(sql, index); return get(ErrorCode.SYNTAX_ERROR_1, sql); }
@Override public void createDirectory() { if (exists() && isDirectory()) { throw DbException.get(ErrorCode.FILE_CREATION_FAILED_1, name + " (a file with this name already exists)"); } // TODO directories are not really supported }
/** * Checks that this user has the given rights for this database object. * * @param table the database object * @param rightMask the rights required * @throws DbException if this user does not have the required rights */ public void checkRight(Table table, int rightMask) { if (!hasRight(table, rightMask)) { throw DbException.get(ErrorCode.NOT_ENOUGH_RIGHTS_FOR_1, table.getSQL()); } }
public void setGranteeName(String granteeName) { Database db = session.getDatabase(); grantee = db.findUser(granteeName); if (grantee == null) { grantee = db.findRole(granteeName); if (grantee == null) { throw DbException.get(ErrorCode.USER_OR_ROLE_NOT_FOUND_1, granteeName); } } }
private Cursor find(Session session, SearchRow first, boolean bigger, SearchRow last) { if (SysProperties.CHECK && store == null) { throw DbException.get(ErrorCode.OBJECT_CLOSED); } PageBtree root = getPage(rootPageId); PageBtreeCursor cursor = new PageBtreeCursor(session, this, last); root.find(cursor, first, bigger); return cursor; }
public DbException getNewDuplicateKeyException() { String sql = "PRIMARY KEY ON " + table.getSQL(); if (mainIndexColumn >= 0 && mainIndexColumn < indexColumns.length) { sql += "(" + indexColumns[mainIndexColumn].getSQL() + ")"; } DbException e = DbException.get(ErrorCode.DUPLICATE_KEY_1, sql); e.setSource(this); return e; }
private boolean nextRow() { if (result.isLazy() && stat.isCancelled()) { throw DbException.get(ErrorCode.STATEMENT_WAS_CANCELED); } boolean next = result.next(); if (!next && !scrollable) { result.close(); } return next; }
@Override public Expression optimize(Session session) { left = left.optimize(session); query.setRandomAccessResult(true); session.optimizeQueryExpression(query); if (query.getColumnCount() != 1) { throw DbException.get(ErrorCode.SUBQUERY_IS_NOT_SINGLE_COLUMN); } // Can not optimize: the data may change return this; }