当前位置: 首页>>代码示例>>Java>>正文


Java DbException.getInvalidValueException方法代码示例

本文整理汇总了Java中org.h2.message.DbException.getInvalidValueException方法的典型用法代码示例。如果您正苦于以下问题:Java DbException.getInvalidValueException方法的具体用法?Java DbException.getInvalidValueException怎么用?Java DbException.getInvalidValueException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.h2.message.DbException的用法示例。


在下文中一共展示了DbException.getInvalidValueException方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setLockMode

import org.h2.message.DbException; //导入方法依赖的package包/类
public void setLockMode(int lockMode) {
    switch (lockMode) {
    case Constants.LOCK_MODE_OFF:
        if (multiThreaded) {
            // currently the combination of LOCK_MODE=0 and MULTI_THREADED
            // is not supported. also see code in
            // JdbcDatabaseMetaData#supportsTransactionIsolationLevel(int)
            throw DbException.get(
                    ErrorCode.UNSUPPORTED_SETTING_COMBINATION,
                    "LOCK_MODE=0 & MULTI_THREADED");
        }
        break;
    case Constants.LOCK_MODE_READ_COMMITTED:
    case Constants.LOCK_MODE_TABLE:
    case Constants.LOCK_MODE_TABLE_GC:
        break;
    default:
        throw DbException.getInvalidValueException("lock mode", lockMode);
    }
    this.lockMode = lockMode;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:22,代码来源:Database.java

示例2: getBigDecimal

import org.h2.message.DbException; //导入方法依赖的package包/类
/**
 * Returns the value of the specified column as a BigDecimal.
 *
 * @deprecated use {@link #getBigDecimal(int)}
 *
 * @param columnIndex (1,2,...)
 * @param scale the scale of the returned value
 * @return the value
 * @throws SQLException if the column is not found or if the result set is
 *             closed
 */
@Override
public BigDecimal getBigDecimal(int columnIndex, int scale)
        throws SQLException {
    try {
        if (isDebugEnabled()) {
            debugCode("getBigDecimal(" + columnIndex + ", " + scale + ");");
        }
        if (scale < 0) {
            throw DbException.getInvalidValueException("scale", scale);
        }
        BigDecimal bd = get(columnIndex).getBigDecimal();
        return bd == null ? null : ValueDecimal.setScale(bd, scale);
    } catch (Exception e) {
        throw logAndConvert(e);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:28,代码来源:JdbcResultSet.java

示例3: setFetchSize

import org.h2.message.DbException; //导入方法依赖的package包/类
/**
 * Sets the number of rows suggested to read in one step. This value cannot
 * be higher than the maximum rows (setMaxRows) set by the statement or
 * prepared statement, otherwise an exception is throws. Setting the value
 * to 0 will set the default value. The default value can be changed using
 * the system property h2.serverResultSetFetchSize.
 *
 * @param rows the number of rows
 */
@Override
public void setFetchSize(int rows) throws SQLException {
    try {
        debugCodeCall("setFetchSize", rows);
        checkClosed();
        if (rows < 0) {
            throw DbException.getInvalidValueException("rows", rows);
        } else if (rows > 0) {
            if (stat != null) {
                int maxRows = stat.getMaxRows();
                if (maxRows > 0 && rows > maxRows) {
                    throw DbException.getInvalidValueException("rows", rows);
                }
            }
        } else {
            rows = SysProperties.SERVER_RESULT_SET_FETCH_SIZE;
        }
        result.setFetchSize(rows);
    } catch (Exception e) {
        throw logAndConvert(e);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:32,代码来源:JdbcResultSet.java

示例4: getDatePart

import org.h2.message.DbException; //导入方法依赖的package包/类
private static int getDatePart(String part) {
    Integer p = DATE_PART.get(StringUtils.toUpperEnglish(part));
    if (p == null) {
        throw DbException.getInvalidValueException("date part", part);
    }
    return p.intValue();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:8,代码来源:Function.java

示例5: checkHoldability

import org.h2.message.DbException; //导入方法依赖的package包/类
private static void checkHoldability(int resultSetHoldability) {
    // TODO compatibility / correctness: DBPool uses
    // ResultSet.HOLD_CURSORS_OVER_COMMIT
    if (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT
            && resultSetHoldability != ResultSet.CLOSE_CURSORS_AT_COMMIT) {
        throw DbException.getInvalidValueException("resultSetHoldability",
                resultSetHoldability);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:10,代码来源:JdbcConnection.java

示例6: readPositiveInt

import org.h2.message.DbException; //导入方法依赖的package包/类
private int readPositiveInt() {
    int v = readInt();
    if (v < 0) {
        throw DbException.getInvalidValueException("positive integer", v);
    }
    return v;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:8,代码来源:Parser.java

示例7: unwrap

import org.h2.message.DbException; //导入方法依赖的package包/类
/**
 * Return an object of this class if possible.
 *
 * @param iface the class
 * @return this
 */
@Override
@SuppressWarnings("unchecked")
public <T> T unwrap(Class<T> iface) throws SQLException {
    if (isWrapperFor(iface)) {
        return (T) this;
    }
    throw DbException.getInvalidValueException("iface", iface);
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:15,代码来源:JdbcStatement.java

示例8: parseSetBinaryCollation

import org.h2.message.DbException; //导入方法依赖的package包/类
private Set parseSetBinaryCollation() {
    Set command = new Set(session, SetTypes.BINARY_COLLATION);
    String name = readAliasIdentifier();
    command.setString(name);
    if (equalsToken(name, CompareMode.UNSIGNED) ||
            equalsToken(name, CompareMode.SIGNED)) {
        return command;
    }
    throw DbException.getInvalidValueException("BINARY_COLLATION", name);
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:11,代码来源:Parser.java

示例9: convertToLocal

import org.h2.message.DbException; //导入方法依赖的package包/类
/**
 * Convert a date to the specified time zone.
 *
 * @param x the date to convert
 * @param target the calendar with the target timezone
 * @return the milliseconds in UTC
 */
public static long convertToLocal(java.util.Date x, Calendar target) {
    if (target == null) {
        throw DbException.getInvalidValueException("calendar", null);
    }
    target = (Calendar) target.clone();
    Calendar local = Calendar.getInstance();
    synchronized (local) {
        local.setTime(x);
        convertTime(local, target);
    }
    return target.getTime().getTime();
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:20,代码来源:DateTimeUtils.java

示例10: getSubString

import org.h2.message.DbException; //导入方法依赖的package包/类
/**
 * Returns a substring.
 *
 * @param pos the position (the first character is at position 1)
 * @param length the number of characters
 * @return the string
 */
@Override
public String getSubString(long pos, int length) throws SQLException {
    try {
        if (isDebugEnabled()) {
            debugCode("getSubString(" + pos + ", " + length + ");");
        }
        checkClosed();
        if (pos < 1) {
            throw DbException.getInvalidValueException("pos", pos);
        }
        if (length < 0) {
            throw DbException.getInvalidValueException("length", length);
        }
        StringWriter writer = new StringWriter(
                Math.min(Constants.IO_BUFFER_SIZE, length));
        Reader reader = value.getReader();
        try {
            IOUtils.skipFully(reader, pos - 1);
            IOUtils.copyAndCloseInput(reader, writer, length);
        } finally {
            reader.close();
        }
        return writer.toString();
    } catch (Exception e) {
        throw logAndConvert(e);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:35,代码来源:JdbcClob.java

示例11: get

import org.h2.message.DbException; //导入方法依赖的package包/类
private Object[] get(long index, int count) {
    Object[] array = get();
    if (count < 0 || count > array.length) {
        throw DbException.getInvalidValueException("count (1.."
                + array.length + ")", count);
    }
    if (index < 1 || index > array.length) {
        throw DbException.getInvalidValueException("index (1.."
                + array.length + ")", index);
    }
    Object[] subset = new Object[count];
    System.arraycopy(array, (int) (index - 1), subset, 0, count);
    return subset;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:15,代码来源:JdbcArray.java

示例12: setParameter

import org.h2.message.DbException; //导入方法依赖的package包/类
private void setParameter(int parameterIndex, Value value) {
    checkClosed();
    parameterIndex--;
    ArrayList<? extends ParameterInterface> parameters = command.getParameters();
    if (parameterIndex < 0 || parameterIndex >= parameters.size()) {
        throw DbException.getInvalidValueException("parameterIndex",
                parameterIndex + 1);
    }
    ParameterInterface param = parameters.get(parameterIndex);
    // can only delete old temp files if they are not in the batch
    param.setValue(value, batchParameters == null);
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:13,代码来源:JdbcPreparedStatement.java

示例13: convertTime

import org.h2.message.DbException; //导入方法依赖的package包/类
/**
 * Convert the time using the specified calendar.
 *
 * @param x the time
 * @param calendar the calendar
 * @return the time
 */
public static ValueTime convertTime(Time x, Calendar calendar) {
    if (calendar == null) {
        throw DbException.getInvalidValueException("calendar", null);
    }
    Calendar cal = (Calendar) calendar.clone();
    cal.setTimeInMillis(x.getTime());
    long nanos = nanosFromCalendar(cal);
    return ValueTime.fromNanos(nanos);
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:17,代码来源:DateTimeUtils.java

示例14: getHash

import org.h2.message.DbException; //导入方法依赖的package包/类
private static byte[] getHash(String algorithm, byte[] bytes, int iterations) {
    if (!"SHA256".equalsIgnoreCase(algorithm)) {
        throw DbException.getInvalidValueException("algorithm", algorithm);
    }
    for (int i = 0; i < iterations; i++) {
        bytes = SHA256.getHash(bytes, false);
    }
    return bytes;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:10,代码来源:Function.java

示例15: setTransactionIsolation

import org.h2.message.DbException; //导入方法依赖的package包/类
/**
 * Changes the current transaction isolation level. Calling this method will
 * commit an open transaction, even if the new level is the same as the old
 * one, except if the level is not supported. Internally, this method calls
 * SET LOCK_MODE, which affects all connections.
 * The following isolation levels are supported:
 * <ul>
 * <li> Connection.TRANSACTION_READ_UNCOMMITTED = SET LOCK_MODE 0: no
 * locking (should only be used for testing). </li>
 * <li>Connection.TRANSACTION_SERIALIZABLE = SET LOCK_MODE 1: table level
 * locking. </li>
 * <li>Connection.TRANSACTION_READ_COMMITTED = SET LOCK_MODE 3: table
 * level locking, but read locks are released immediately (default). </li>
 * </ul>
 * This setting is not persistent. Please note that using
 * TRANSACTION_READ_UNCOMMITTED while at the same time using multiple
 * connections may result in inconsistent transactions.
 *
 * @param level the new transaction isolation level:
 *            Connection.TRANSACTION_READ_UNCOMMITTED,
 *            Connection.TRANSACTION_READ_COMMITTED, or
 *            Connection.TRANSACTION_SERIALIZABLE
 * @throws SQLException if the connection is closed or the isolation level
 *             is not supported
 */
@Override
public void setTransactionIsolation(int level) throws SQLException {
    try {
        debugCodeCall("setTransactionIsolation", level);
        checkClosed();
        int lockMode;
        switch(level) {
        case Connection.TRANSACTION_READ_UNCOMMITTED:
            lockMode = Constants.LOCK_MODE_OFF;
            break;
        case Connection.TRANSACTION_READ_COMMITTED:
            lockMode = Constants.LOCK_MODE_READ_COMMITTED;
            break;
        case Connection.TRANSACTION_REPEATABLE_READ:
        case Connection.TRANSACTION_SERIALIZABLE:
            lockMode = Constants.LOCK_MODE_TABLE;
            break;
        default:
            throw DbException.getInvalidValueException("level", level);
        }
        commit();
        setLockMode = prepareCommand("SET LOCK_MODE ?", setLockMode);
        setLockMode.getParameters().get(0).setValue(ValueInt.get(lockMode), false);
        setLockMode.executeUpdate();
    } catch (Exception e) {
        throw logAndConvert(e);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:54,代码来源:JdbcConnection.java


注:本文中的org.h2.message.DbException.getInvalidValueException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。