public void setIncrement(long inc) throws SQLException { if (inc == 0) { throw Message.getSQLException(ErrorCode.INVALID_VALUE_2, new String[] { "0", "INCREMENT" }, null); } this.increment = inc; }
public SQLException getFormatException() { String format = Constants.URL_FORMAT; return Message.getSQLException(ErrorCode.URL_FORMAT_ERROR_2, new String[] { format, url }); } }
private void mapColumn(ColumnResolver resolver, Column col, int level) throws SQLException { if (this.resolver == null) { queryLevel = level; column = col; this.resolver = resolver; } else if (queryLevel == level && this.resolver != resolver) { throw Message.getSQLException(ErrorCode.AMBIGUOUS_COLUMN_NAME_1, columnName); } }
/** * Check if this user has admin rights. An exception is thrown if he does * not have them. * * @throws SQLException if this user is not an admin */ public void checkAdmin() throws SQLException { if (!admin) { throw Message.getSQLException(ErrorCode.ADMIN_RIGHTS_REQUIRED); } }
private byte convertToByte(long x) throws SQLException { if (x > Byte.MAX_VALUE || x < Byte.MIN_VALUE) { throw Message.getSQLException(ErrorCode.NUMERIC_VALUE_OUT_OF_RANGE); } return (byte) x; }
public Sequence getSequence(String sequenceName) throws SQLException { Sequence sequence = (Sequence) sequences.get(sequenceName); if (sequence == null) { throw Message.getSQLException(ErrorCode.SEQUENCE_NOT_FOUND_1, sequenceName); } return sequence; }
private long convertToLong(double x) throws SQLException { if (x > Long.MAX_VALUE || x < Long.MIN_VALUE) { // TODO document that +Infinity, -Infinity throw an exception and NaN returns 0 throw Message.getSQLException(ErrorCode.NUMERIC_VALUE_OUT_OF_RANGE); } if (Constants.CONVERT_TO_LONG_ROUND) { return Math.round(x); } else { return (long) x; } }
public static SQLException convertIOException(IOException e, String message) { if (message == null) { return getSQLException(ErrorCode.IO_EXCEPTION_1, new String[]{e.toString()}, e); } else { return getSQLException(ErrorCode.IO_EXCEPTION_2, new String[]{e.toString(), message}, e); } }
DatabaseEventListener removeDatabaseEventListenerObject() throws SQLException { Object p = prop.remove("DATABASE_EVENT_LISTENER_OBJECT"); if (p == null) { return null; } if (p instanceof DatabaseEventListener) { return (DatabaseEventListener) p; } throw Message.getSQLException(ErrorCode.DATA_CONVERSION_ERROR_1, p.getClass().getName()); }
protected void checkParameterCount(int len) throws SQLException { if (len < 1) { throw Message.getSQLException(ErrorCode.INVALID_PARAMETER_COUNT_2, new String[] { getName(), ">0" }); } }
private void resetResult() throws SQLException { if (!scrollable) { throw Message.getSQLException(ErrorCode.RESULT_SET_NOT_SCROLLABLE); } result.reset(); }
/** * Check if this session is closed and throws an exception if so. * * @throws SQLException if the session is closed */ public void checkClosed() throws SQLException { if (isClosed()) { // TODO broken connection: try to reconnect automatically throw Message.getSQLException(ErrorCode.CONNECTION_BROKEN); } }
private void checkSchema(Schema old) throws SQLException { if (old != null && getSchema() != old) { throw Message.getSQLException(ErrorCode.SCHEMA_NAME_MUST_MATCH); } }
private static int getDatePart(String part) throws SQLException { Integer p = (Integer) DATE_PART.get(StringUtils.toUpperEnglish(part)); if (p == null) { throw Message.getSQLException(ErrorCode.INVALID_VALUE_2, new String[] { "date part", part }); } return p.intValue(); }
private void checkClosed() throws SQLException { conn.checkClosed(); if (value == null) { throw Message.getSQLException(ErrorCode.OBJECT_CLOSED); } }
private ValueDecimal(BigDecimal value) { if (value == null) { throw new IllegalArgumentException(); } else if (!SysProperties.ALLOW_BIG_DECIMAL_EXTENSIONS && !value.getClass().equals(BigDecimal.class)) { SQLException e = Message.getSQLException(ErrorCode.INVALID_CLASS_2, new String[] { BigDecimal.class.getName(), value.getClass().getName() }); throw Message.convertToInternal(e); } this.value = value; }
private ValueInt checkRange(long value) throws SQLException { if (value < Integer.MIN_VALUE || value > Integer.MAX_VALUE) { throw Message.getSQLException(ErrorCode.OVERFLOW_FOR_TYPE_1, DataType.getDataType(Value.INT).name); } else { return ValueInt.get((int) value); } }
private UpdatableRow getUpdatableRow() throws SQLException { UpdatableRow row = new UpdatableRow(conn, result, session); if (!row.isUpdatable()) { throw Message.getSQLException(ErrorCode.RESULT_SET_NOT_UPDATABLE); } return row; }
public Index getScanIndex(Session session) throws SQLException { if (createException != null) { String msg = createException.getMessage(); throw Message.getSQLException(ErrorCode.VIEW_IS_INVALID_2, new String[] { getSQL(), msg }, createException); } PlanItem item = getBestPlanItem(session, null); return item.getIndex(); }
public void checkRow(Session session, Table t, Row oldRow, Row newRow) throws SQLException { if (newRow == null) { return; } filter.set(newRow); // Both TRUE and NULL are ok if (Boolean.FALSE.equals(expr.getValue(session).getBoolean())) { throw Message.getSQLException(ErrorCode.CHECK_CONSTRAINT_VIOLATED_1, getShortDescription()); } }