提交 f945dbb6 authored 作者: Thomas Mueller's avatar Thomas Mueller

For an invalid value exception, the parameter name and value was switched in some cases.

上级 49ae2b23
...@@ -2287,7 +2287,7 @@ public class Parser { ...@@ -2287,7 +2287,7 @@ public class Parser {
} }
int index = currentValue.getInt() - 1; int index = currentValue.getInt() - 1;
if (index < 0 || index >= Constants.MAX_PARAMETER_INDEX) { if (index < 0 || index >= Constants.MAX_PARAMETER_INDEX) {
throw DbException.getInvalidValueException("" + index, "Parameter Index"); throw DbException.getInvalidValueException("parameter index", index);
} }
if (indexedParameterList.size() <= index) { if (indexedParameterList.size() <= index) {
indexedParameterList.ensureCapacity(index + 1); indexedParameterList.ensureCapacity(index + 1);
...@@ -2544,7 +2544,7 @@ public class Parser { ...@@ -2544,7 +2544,7 @@ public class Parser {
private int getPositiveInt() { private int getPositiveInt() {
int v = getInt(); int v = getInt();
if (v < 0) { if (v < 0) {
throw DbException.getInvalidValueException("" + v, "positive integer"); throw DbException.getInvalidValueException("positive integer", v);
} }
return v; return v;
} }
......
...@@ -70,7 +70,7 @@ public class AlterSequence extends SchemaCommand { ...@@ -70,7 +70,7 @@ public class AlterSequence extends SchemaCommand {
if (increment != null) { if (increment != null) {
long incrementValue = increment.optimize(session).getValue(session).getLong(); long incrementValue = increment.optimize(session).getValue(session).getLong();
if (incrementValue == 0) { if (incrementValue == 0) {
throw DbException.get(ErrorCode.INVALID_VALUE_2, "0", "INCREMENT"); throw DbException.getInvalidValueException("INCREMENT", 0);
} }
sequence.setIncrement(incrementValue); sequence.setIncrement(incrementValue);
} }
......
...@@ -386,7 +386,7 @@ public class Select extends Query { ...@@ -386,7 +386,7 @@ public class Select extends Query {
ArrayList<Column> sortColumns = New.arrayList(); ArrayList<Column> sortColumns = New.arrayList();
for (int idx : sort.getIndexes()) { for (int idx : sort.getIndexes()) {
if (idx < 0 || idx >= expressions.size()) { if (idx < 0 || idx >= expressions.size()) {
throw DbException.getInvalidValueException("" + (idx + 1), "ORDER BY"); throw DbException.getInvalidValueException("ORDER BY", idx + 1);
} }
Expression expr = expressions.get(idx); Expression expr = expressions.get(idx);
expr = expr.getNonAliasExpression(); expr = expr.getNonAliasExpression();
......
...@@ -72,7 +72,7 @@ public class Set extends Prepared { ...@@ -72,7 +72,7 @@ public class Set extends Prepared {
session.getUser().checkAdmin(); session.getUser().checkAdmin();
int value = getIntValue(); int value = getIntValue();
if (value < 0 || value > 2) { if (value < 0 || value > 2) {
throw DbException.getInvalidValueException("" + getIntValue(), "ALLOW_LITERALS"); throw DbException.getInvalidValueException("ALLOW_LITERALS", getIntValue());
} }
database.setAllowLiterals(value); database.setAllowLiterals(value);
addOrUpdateSetting(name, null, value); addOrUpdateSetting(name, null, value);
...@@ -181,7 +181,7 @@ public class Set extends Prepared { ...@@ -181,7 +181,7 @@ public class Set extends Prepared {
database.setExclusiveSession(session, true); database.setExclusiveSession(session, true);
break; break;
default: default:
throw DbException.getInvalidValueException("" + value, "EXCLUSIVE"); throw DbException.getInvalidValueException("EXCLUSIVE", value);
} }
break; break;
} }
...@@ -201,7 +201,7 @@ public class Set extends Prepared { ...@@ -201,7 +201,7 @@ public class Set extends Prepared {
case SetTypes.LOG: { case SetTypes.LOG: {
int value = getIntValue(); int value = getIntValue();
if (value < 0 || value > 2) { if (value < 0 || value > 2) {
throw DbException.getInvalidValueException("" + getIntValue(), "LOG"); throw DbException.getInvalidValueException("LOG", getIntValue());
} }
if (value == 0) { if (value == 0) {
session.getUser().checkAdmin(); session.getUser().checkAdmin();
...@@ -211,7 +211,7 @@ public class Set extends Prepared { ...@@ -211,7 +211,7 @@ public class Set extends Prepared {
} }
case SetTypes.MAX_LENGTH_INPLACE_LOB: { case SetTypes.MAX_LENGTH_INPLACE_LOB: {
if (getIntValue() < 0) { if (getIntValue() < 0) {
throw DbException.getInvalidValueException("" + getIntValue(), "MAX_LENGTH_INPLACE_LOB"); throw DbException.getInvalidValueException("MAX_LENGTH_INPLACE_LOB", getIntValue());
} }
session.getUser().checkAdmin(); session.getUser().checkAdmin();
database.setMaxLengthInplaceLob(getIntValue()); database.setMaxLengthInplaceLob(getIntValue());
...@@ -231,7 +231,7 @@ public class Set extends Prepared { ...@@ -231,7 +231,7 @@ public class Set extends Prepared {
} }
case SetTypes.MAX_MEMORY_UNDO: { case SetTypes.MAX_MEMORY_UNDO: {
if (getIntValue() < 0) { if (getIntValue() < 0) {
throw DbException.getInvalidValueException("" + getIntValue(), "MAX_MEMORY_UNDO"); throw DbException.getInvalidValueException("MAX_MEMORY_UNDO", getIntValue());
} }
session.getUser().checkAdmin(); session.getUser().checkAdmin();
database.setMaxMemoryUndo(getIntValue()); database.setMaxMemoryUndo(getIntValue());
...@@ -282,7 +282,7 @@ public class Set extends Prepared { ...@@ -282,7 +282,7 @@ public class Set extends Prepared {
session.getUser().checkAdmin(); session.getUser().checkAdmin();
int value = getIntValue(); int value = getIntValue();
if (value < 0 || value > 1) { if (value < 0 || value > 1) {
throw DbException.getInvalidValueException("" + getIntValue(), "REFERENTIAL_INTEGRITY"); throw DbException.getInvalidValueException("REFERENTIAL_INTEGRITY", getIntValue());
} }
database.setReferentialIntegrity(value == 1); database.setReferentialIntegrity(value == 1);
break; break;
...@@ -323,7 +323,7 @@ public class Set extends Prepared { ...@@ -323,7 +323,7 @@ public class Set extends Prepared {
} }
case SetTypes.THROTTLE: { case SetTypes.THROTTLE: {
if (getIntValue() < 0) { if (getIntValue() < 0) {
throw DbException.getInvalidValueException("" + getIntValue(), "THROTTLE"); throw DbException.getInvalidValueException("THROTTLE", getIntValue());
} }
session.setThrottle(getIntValue()); session.setThrottle(getIntValue());
break; break;
...@@ -331,7 +331,7 @@ public class Set extends Prepared { ...@@ -331,7 +331,7 @@ public class Set extends Prepared {
case SetTypes.UNDO_LOG: { case SetTypes.UNDO_LOG: {
int value = getIntValue(); int value = getIntValue();
if (value < 0 || value > 1) { if (value < 0 || value > 1) {
throw DbException.getInvalidValueException("" + getIntValue(), "UNDO_LOG"); throw DbException.getInvalidValueException("UNDO_LOG", getIntValue());
} }
session.setUndoLogEnabled(value == 1); session.setUndoLogEnabled(value == 1);
break; break;
......
...@@ -66,7 +66,7 @@ public class ConnectionInfo implements Cloneable { ...@@ -66,7 +66,7 @@ public class ConnectionInfo implements Cloneable {
public ConnectionInfo(String u, Properties info) { public ConnectionInfo(String u, Properties info) {
this.originalURL = u; this.originalURL = u;
if (!u.startsWith(Constants.START_URL)) { if (!u.startsWith(Constants.START_URL)) {
throw DbException.getInvalidValueException(u, "url"); throw DbException.getInvalidValueException("url", u);
} }
this.url = u; this.url = u;
readProperties(info); readProperties(info);
......
...@@ -1797,7 +1797,7 @@ public class Database implements DataHandler { ...@@ -1797,7 +1797,7 @@ public class Database implements DataHandler {
case Constants.LOCK_MODE_TABLE_GC: case Constants.LOCK_MODE_TABLE_GC:
break; break;
default: default:
throw DbException.getInvalidValueException("lock mode", "" + lockMode); throw DbException.getInvalidValueException("lock mode", lockMode);
} }
this.lockMode = lockMode; this.lockMode = lockMode;
} }
......
...@@ -251,12 +251,12 @@ public class JdbcArray extends TraceObject implements Array { ...@@ -251,12 +251,12 @@ public class JdbcArray extends TraceObject implements Array {
private Object[] get(long index, int count) { private Object[] get(long index, int count) {
Object[] array = get(); Object[] array = get();
if (count < 0 || count > array.length) { if (count < 0 || count > array.length) {
throw DbException.getInvalidValueException("" + count, "count (1.." throw DbException.getInvalidValueException("count (1.."
+ array.length + ")"); + array.length + ")", count);
} }
if (index < 1 || index > array.length) { if (index < 1 || index > array.length) {
throw DbException.getInvalidValueException("" + index, "index (1.." throw DbException.getInvalidValueException("index (1.."
+ array.length + ")"); + array.length + ")", index);
} }
Object[] subset = new Object[count]; Object[] subset = new Object[count];
System.arraycopy(array, (int) (index - 1), subset, 0, count); System.arraycopy(array, (int) (index - 1), subset, 0, count);
......
...@@ -1485,7 +1485,7 @@ public class JdbcCallableStatement extends JdbcPreparedStatement implements Call ...@@ -1485,7 +1485,7 @@ public class JdbcCallableStatement extends JdbcPreparedStatement implements Call
private void checkIndexBounds(int parameterIndex) throws SQLException { private void checkIndexBounds(int parameterIndex) throws SQLException {
checkClosed(); checkClosed();
if (parameterIndex < 1 || parameterIndex > maxOutParameters) { if (parameterIndex < 1 || parameterIndex > maxOutParameters) {
throw DbException.getInvalidValueException("" + parameterIndex, "parameterIndex"); throw DbException.getInvalidValueException("parameterIndex", parameterIndex);
} }
} }
...@@ -1513,7 +1513,7 @@ public class JdbcCallableStatement extends JdbcPreparedStatement implements Call ...@@ -1513,7 +1513,7 @@ public class JdbcCallableStatement extends JdbcPreparedStatement implements Call
try { try {
checkIndexBounds(parameterIndex); checkIndexBounds(parameterIndex);
if (!outParameters.get(parameterIndex - 1)) { if (!outParameters.get(parameterIndex - 1)) {
throw DbException.getInvalidValueException("" + parameterIndex, "parameterIndex"); throw DbException.getInvalidValueException("parameterIndex", parameterIndex);
} }
} catch (Exception e) { } catch (Exception e) {
throw logAndConvert(e); throw logAndConvert(e);
...@@ -1534,7 +1534,7 @@ public class JdbcCallableStatement extends JdbcPreparedStatement implements Call ...@@ -1534,7 +1534,7 @@ public class JdbcCallableStatement extends JdbcPreparedStatement implements Call
} }
Integer index = namedParameters.get(parameterName); Integer index = namedParameters.get(parameterName);
if (index == null) { if (index == null) {
throw DbException.getInvalidValueException(parameterName, "parameterName"); throw DbException.getInvalidValueException("parameterName", parameterName);
} }
return index; return index;
} catch (Exception e) { } catch (Exception e) {
......
...@@ -629,7 +629,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -629,7 +629,7 @@ public class JdbcConnection extends TraceObject implements Connection {
lockMode = Constants.LOCK_MODE_TABLE; lockMode = Constants.LOCK_MODE_TABLE;
break; break;
default: default:
throw DbException.getInvalidValueException("" + level, "level"); throw DbException.getInvalidValueException("level", level);
} }
commit(); commit();
setLockMode = prepareCommand("SET LOCK_MODE ?", setLockMode); setLockMode = prepareCommand("SET LOCK_MODE ?", setLockMode);
...@@ -1142,7 +1142,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -1142,7 +1142,7 @@ public class JdbcConnection extends TraceObject implements Connection {
*/ */
String translateSQL(String sql, boolean escapeProcessing) { String translateSQL(String sql, boolean escapeProcessing) {
if (sql == null) { if (sql == null) {
throw DbException.getInvalidValueException(sql, "SQL"); throw DbException.getInvalidValueException("SQL", sql);
} }
if (!escapeProcessing) { if (!escapeProcessing) {
return sql; return sql;
...@@ -1275,14 +1275,14 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -1275,14 +1275,14 @@ public class JdbcConnection extends TraceObject implements Connection {
case ResultSet.TYPE_SCROLL_SENSITIVE: case ResultSet.TYPE_SCROLL_SENSITIVE:
break; break;
default: default:
throw DbException.getInvalidValueException("" + resultSetType, "resultSetType"); throw DbException.getInvalidValueException("resultSetType", resultSetType);
} }
switch (resultSetConcurrency) { switch (resultSetConcurrency) {
case ResultSet.CONCUR_READ_ONLY: case ResultSet.CONCUR_READ_ONLY:
case ResultSet.CONCUR_UPDATABLE: case ResultSet.CONCUR_UPDATABLE:
break; break;
default: default:
throw DbException.getInvalidValueException("" + resultSetConcurrency, "resultSetConcurrency"); throw DbException.getInvalidValueException("resultSetConcurrency", resultSetConcurrency);
} }
} }
...@@ -1292,7 +1292,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -1292,7 +1292,7 @@ public class JdbcConnection extends TraceObject implements Connection {
//## Java 1.4 begin ## //## Java 1.4 begin ##
if (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT if (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT
&& resultSetHoldability != ResultSet.CLOSE_CURSORS_AT_COMMIT) { && resultSetHoldability != ResultSet.CLOSE_CURSORS_AT_COMMIT) {
throw DbException.getInvalidValueException("" + resultSetHoldability, "resultSetHoldability"); throw DbException.getInvalidValueException("resultSetHoldability", resultSetHoldability);
} }
//## Java 1.4 end ## //## Java 1.4 end ##
} }
......
...@@ -205,7 +205,7 @@ implements ParameterMetaData ...@@ -205,7 +205,7 @@ implements ParameterMetaData
private ParameterInterface getParameter(int param) throws SQLException { private ParameterInterface getParameter(int param) throws SQLException {
checkClosed(); checkClosed();
if (param < 1 || param > paramCount) { if (param < 1 || param > paramCount) {
throw DbException.getInvalidValueException("" + param, "param"); throw DbException.getInvalidValueException("param", param);
} }
return parameters.get(param - 1); return parameters.get(param - 1);
} }
......
...@@ -1256,7 +1256,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat ...@@ -1256,7 +1256,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
parameterIndex--; parameterIndex--;
ArrayList< ? extends ParameterInterface> parameters = command.getParameters(); ArrayList< ? extends ParameterInterface> parameters = command.getParameters();
if (parameterIndex < 0 || parameterIndex >= parameters.size()) { if (parameterIndex < 0 || parameterIndex >= parameters.size()) {
throw DbException.getInvalidValueException("" + (parameterIndex + 1), "parameterIndex"); throw DbException.getInvalidValueException("parameterIndex", parameterIndex + 1);
} }
ParameterInterface param = parameters.get(parameterIndex); ParameterInterface param = parameters.get(parameterIndex);
// can only delete old temp files if they are not in the batch // can only delete old temp files if they are not in the batch
......
...@@ -709,7 +709,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet { ...@@ -709,7 +709,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
debugCode("getBigDecimal(" + StringUtils.quoteJavaString(columnLabel)+", "+scale+");"); debugCode("getBigDecimal(" + StringUtils.quoteJavaString(columnLabel)+", "+scale+");");
} }
if (scale < 0) { if (scale < 0) {
throw DbException.getInvalidValueException("" + scale, "scale"); throw DbException.getInvalidValueException("scale", scale);
} }
BigDecimal bd = get(columnLabel).getBigDecimal(); BigDecimal bd = get(columnLabel).getBigDecimal();
return bd == null ? null : MathUtils.setScale(bd, scale); return bd == null ? null : MathUtils.setScale(bd, scale);
...@@ -734,7 +734,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet { ...@@ -734,7 +734,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
debugCode("getBigDecimal(" + columnIndex + ", " + scale + ");"); debugCode("getBigDecimal(" + columnIndex + ", " + scale + ");");
} }
if (scale < 0) { if (scale < 0) {
throw DbException.getInvalidValueException("" + scale, "scale"); throw DbException.getInvalidValueException("scale", scale);
} }
BigDecimal bd = get(columnIndex).getBigDecimal(); BigDecimal bd = get(columnIndex).getBigDecimal();
return bd == null ? null : MathUtils.setScale(bd, scale); return bd == null ? null : MathUtils.setScale(bd, scale);
...@@ -2377,14 +2377,13 @@ public class JdbcResultSet extends TraceObject implements ResultSet { ...@@ -2377,14 +2377,13 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
try { try {
debugCodeCall("setFetchSize", rows); debugCodeCall("setFetchSize", rows);
checkClosed(); checkClosed();
if (rows < 0) { if (rows < 0) {
throw DbException.getInvalidValueException("" + rows, "rows"); throw DbException.getInvalidValueException("rows", rows);
} else if (rows > 0) { } else if (rows > 0) {
if (stat != null) { if (stat != null) {
int maxRows = stat.getMaxRows(); int maxRows = stat.getMaxRows();
if (maxRows > 0 && rows > maxRows) { if (maxRows > 0 && rows > maxRows) {
throw DbException.getInvalidValueException("" + rows, "rows"); throw DbException.getInvalidValueException("rows", rows);
} }
} }
} else { } else {
...@@ -2914,7 +2913,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet { ...@@ -2914,7 +2913,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet {
private void checkColumnIndex(int columnIndex) throws SQLException { private void checkColumnIndex(int columnIndex) throws SQLException {
checkClosed(); checkClosed();
if (columnIndex < 1 || columnIndex > columnCount) { if (columnIndex < 1 || columnIndex > columnCount) {
throw DbException.getInvalidValueException("" + columnIndex, "columnIndex"); throw DbException.getInvalidValueException("columnIndex", columnIndex);
} }
} }
......
...@@ -425,7 +425,7 @@ public class JdbcResultSetMetaData extends TraceObject implements ResultSetMetaD ...@@ -425,7 +425,7 @@ public class JdbcResultSetMetaData extends TraceObject implements ResultSetMetaD
private void checkColumnIndex(int columnIndex) throws SQLException { private void checkColumnIndex(int columnIndex) throws SQLException {
checkClosed(); checkClosed();
if (columnIndex < 1 || columnIndex > columnCount) { if (columnIndex < 1 || columnIndex > columnCount) {
throw DbException.getInvalidValueException("" + columnIndex, "columnIndex"); throw DbException.getInvalidValueException("columnIndex", columnIndex);
} }
} }
......
...@@ -378,7 +378,7 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -378,7 +378,7 @@ public class JdbcStatement extends TraceObject implements Statement {
debugCodeCall("setMaxRows", maxRows); debugCodeCall("setMaxRows", maxRows);
checkClosed(); checkClosed();
if (maxRows < 0) { if (maxRows < 0) {
throw DbException.getInvalidValueException("" + maxRows, "maxRows"); throw DbException.getInvalidValueException("maxRows", maxRows);
} }
this.maxRows = maxRows; this.maxRows = maxRows;
} catch (Exception e) { } catch (Exception e) {
...@@ -402,7 +402,7 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -402,7 +402,7 @@ public class JdbcStatement extends TraceObject implements Statement {
debugCodeCall("setFetchSize", rows); debugCodeCall("setFetchSize", rows);
checkClosed(); checkClosed();
if (rows < 0 || (rows > 0 && maxRows > 0 && rows > maxRows)) { if (rows < 0 || (rows > 0 && maxRows > 0 && rows > maxRows)) {
throw DbException.getInvalidValueException("" + rows, "rows"); throw DbException.getInvalidValueException("rows", rows);
} }
if (rows == 0) { if (rows == 0) {
rows = SysProperties.SERVER_RESULT_SET_FETCH_SIZE; rows = SysProperties.SERVER_RESULT_SET_FETCH_SIZE;
...@@ -570,7 +570,7 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -570,7 +570,7 @@ public class JdbcStatement extends TraceObject implements Statement {
debugCodeCall("setQueryTimeout", seconds); debugCodeCall("setQueryTimeout", seconds);
checkClosed(); checkClosed();
if (seconds < 0) { if (seconds < 0) {
throw DbException.getInvalidValueException("" + seconds, "seconds"); throw DbException.getInvalidValueException("seconds", seconds);
} }
conn.setQueryTimeout(seconds); conn.setQueryTimeout(seconds);
} catch (Exception e) { } catch (Exception e) {
...@@ -695,7 +695,7 @@ public class JdbcStatement extends TraceObject implements Statement { ...@@ -695,7 +695,7 @@ public class JdbcStatement extends TraceObject implements Statement {
// nothing to do // nothing to do
break; break;
default: default:
throw DbException.getInvalidValueException("" + current, "current"); throw DbException.getInvalidValueException("current", current);
} }
return false; return false;
} catch (Exception e) { } catch (Exception e) {
......
...@@ -205,12 +205,12 @@ public class DbException extends RuntimeException { ...@@ -205,12 +205,12 @@ public class DbException extends RuntimeException {
/** /**
* Gets a SQL exception meaning this value is invalid. * Gets a SQL exception meaning this value is invalid.
* *
* @param value the value passed
* @param param the name of the parameter * @param param the name of the parameter
* @param value the value passed
* @return the IllegalArgumentException object * @return the IllegalArgumentException object
*/ */
public static DbException getInvalidValueException(String value, String param) { public static DbException getInvalidValueException(String param, Object value) {
return get(ErrorCode.INVALID_VALUE_2, value, param); return get(ErrorCode.INVALID_VALUE_2, value == null ? "null" : value.toString(), param);
} }
/** /**
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
*/ */
package org.h2.schema; package org.h2.schema;
import org.h2.constant.ErrorCode;
import org.h2.engine.DbObject; import org.h2.engine.DbObject;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.message.DbException; import org.h2.message.DbException;
...@@ -50,7 +49,7 @@ public class Sequence extends SchemaObjectBase { ...@@ -50,7 +49,7 @@ public class Sequence extends SchemaObjectBase {
public void setIncrement(long inc) { public void setIncrement(long inc) {
if (inc == 0) { if (inc == 0) {
throw DbException.get(ErrorCode.INVALID_VALUE_2, "0", "INCREMENT"); throw DbException.getInvalidValueException("INCREMENT", 0);
} }
this.increment = inc; this.increment = inc;
} }
......
...@@ -79,7 +79,7 @@ public class CipherFactory { ...@@ -79,7 +79,7 @@ public class CipherFactory {
if ("SHA256".equalsIgnoreCase(algorithm)) { if ("SHA256".equalsIgnoreCase(algorithm)) {
return new SHA256(); return new SHA256();
} }
throw DbException.getInvalidValueException(algorithm, "algorithm"); throw DbException.getInvalidValueException("algorithm", algorithm);
} }
/** /**
......
...@@ -1619,7 +1619,7 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData { ...@@ -1619,7 +1619,7 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
private void checkColumnIndex(int columnIndex) throws SQLException { private void checkColumnIndex(int columnIndex) throws SQLException {
if (columnIndex < 0 || columnIndex >= columns.size()) { if (columnIndex < 0 || columnIndex >= columns.size()) {
throw DbException.getInvalidValueException("" + columnIndex, "columnIndex").getSQLException(); throw DbException.getInvalidValueException("columnIndex", columnIndex).getSQLException();
} }
} }
......
...@@ -68,7 +68,7 @@ public class CacheLRU implements Cache { ...@@ -68,7 +68,7 @@ public class CacheLRU implements Cache {
if (CacheLRU.TYPE_NAME.equals(cacheType)) { if (CacheLRU.TYPE_NAME.equals(cacheType)) {
cache = new CacheLRU(writer, cacheSize); cache = new CacheLRU(writer, cacheSize);
} else { } else {
throw DbException.getInvalidValueException(cacheType, "CACHE_TYPE"); throw DbException.getInvalidValueException("CACHE_TYPE", cacheType);
} }
if (secondLevel != null) { if (secondLevel != null) {
cache = new CacheSecondLevel(cache, secondLevel); cache = new CacheSecondLevel(cache, secondLevel);
......
...@@ -253,10 +253,8 @@ public class MathUtils { ...@@ -253,10 +253,8 @@ public class MathUtils {
* @return the scaled value * @return the scaled value
*/ */
public static BigDecimal setScale(BigDecimal bd, int scale) { public static BigDecimal setScale(BigDecimal bd, int scale) {
if (scale > BIG_DECIMAL_SCALE_MAX) { if (scale > BIG_DECIMAL_SCALE_MAX || scale < -BIG_DECIMAL_SCALE_MAX) {
throw DbException.getInvalidValueException("" + scale, "scale"); throw DbException.getInvalidValueException("scale", scale);
} else if (scale < -BIG_DECIMAL_SCALE_MAX) {
throw DbException.getInvalidValueException("" + scale, "scale");
} }
return bd.setScale(scale, BigDecimal.ROUND_HALF_UP); return bd.setScale(scale, BigDecimal.ROUND_HALF_UP);
} }
......
...@@ -151,7 +151,7 @@ public class ValueTimestamp extends Value { ...@@ -151,7 +151,7 @@ public class ValueTimestamp extends Value {
public Value convertScale(boolean onlyToSmallerScale, int targetScale) { public Value convertScale(boolean onlyToSmallerScale, int targetScale) {
if (targetScale < 0 || targetScale > DEFAULT_SCALE) { if (targetScale < 0 || targetScale > DEFAULT_SCALE) {
// TODO convertScale for Timestamps: may throw an exception? // TODO convertScale for Timestamps: may throw an exception?
throw DbException.getInvalidValueException("" + targetScale, "scale"); throw DbException.getInvalidValueException("scale", targetScale);
} }
int nanos = value.getNanos(); int nanos = value.getNanos();
BigDecimal bd = BigDecimal.valueOf(nanos); BigDecimal bd = BigDecimal.valueOf(nanos);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论