提交 3bad54e3 authored 作者: Sergi Vladykin's avatar Sergi Vladykin

Compilation for Java 7 fixed, cleanup + code style.

上级 7102cc38
...@@ -30,7 +30,7 @@ public abstract class Command implements CommandInterface { ...@@ -30,7 +30,7 @@ public abstract class Command implements CommandInterface {
/** /**
* The last start time. * The last start time.
*/ */
protected long startTime_nanos; protected long startTimeNanos;
/** /**
* The trace module. * The trace module.
...@@ -127,7 +127,7 @@ public abstract class Command implements CommandInterface { ...@@ -127,7 +127,7 @@ public abstract class Command implements CommandInterface {
*/ */
void start() { void start() {
if (trace.isInfoEnabled() || session.getDatabase().getQueryStatistics()) { if (trace.isInfoEnabled() || session.getDatabase().getQueryStatistics()) {
startTime_nanos = System.nanoTime(); startTimeNanos = System.nanoTime();
} }
} }
...@@ -162,10 +162,10 @@ public abstract class Command implements CommandInterface { ...@@ -162,10 +162,10 @@ public abstract class Command implements CommandInterface {
} }
} }
} }
if (trace.isInfoEnabled() && startTime_nanos > 0) { if (trace.isInfoEnabled() && startTimeNanos > 0) {
long time_ms = (System.nanoTime() - startTime_nanos) / 1000 / 1000; long timeMillis = (System.nanoTime() - startTimeNanos) / 1000 / 1000;
if (time_ms > Constants.SLOW_QUERY_LIMIT_MS) { if (timeMillis > Constants.SLOW_QUERY_LIMIT_MS) {
trace.info("slow query: {0} ms", time_ms); trace.info("slow query: {0} ms", timeMillis);
} }
} }
} }
...@@ -180,7 +180,7 @@ public abstract class Command implements CommandInterface { ...@@ -180,7 +180,7 @@ public abstract class Command implements CommandInterface {
*/ */
@Override @Override
public ResultInterface executeQuery(int maxrows, boolean scrollable) { public ResultInterface executeQuery(int maxrows, boolean scrollable) {
startTime_nanos = 0; startTimeNanos = 0;
long start = 0; long start = 0;
Database database = session.getDatabase(); Database database = session.getDatabase();
Object sync = database.isMultiThreaded() ? (Object) session : (Object) database; Object sync = database.isMultiThreaded() ? (Object) session : (Object) database;
......
...@@ -96,7 +96,7 @@ public class CommandContainer extends Command { ...@@ -96,7 +96,7 @@ public class CommandContainer extends Command {
session.setLastScopeIdentity(ValueNull.INSTANCE); session.setLastScopeIdentity(ValueNull.INSTANCE);
prepared.checkParameters(); prepared.checkParameters();
int updateCount = prepared.update(); int updateCount = prepared.update();
prepared.trace(startTime_nanos, updateCount); prepared.trace(startTimeNanos, updateCount);
setProgress(DatabaseEventListener.STATE_STATEMENT_END); setProgress(DatabaseEventListener.STATE_STATEMENT_END);
return updateCount; return updateCount;
} }
...@@ -108,7 +108,7 @@ public class CommandContainer extends Command { ...@@ -108,7 +108,7 @@ public class CommandContainer extends Command {
start(); start();
prepared.checkParameters(); prepared.checkParameters();
ResultInterface result = prepared.query(maxrows); ResultInterface result = prepared.query(maxrows);
prepared.trace(startTime_nanos, result.getRowCount()); prepared.trace(startTimeNanos, result.getRowCount());
setProgress(DatabaseEventListener.STATE_STATEMENT_END); setProgress(DatabaseEventListener.STATE_STATEMENT_END);
return result; return result;
} }
......
...@@ -1885,8 +1885,9 @@ public class Parser { ...@@ -1885,8 +1885,9 @@ public class Parser {
read(")"); read(")");
return command; return command;
} }
if (readIf("WITH")) if (readIf("WITH")) {
return parseWith(); return parseWith();
}
Select select = parseSelectSimple(); Select select = parseSelectSimple();
return select; return select;
} }
......
...@@ -302,20 +302,20 @@ public abstract class Prepared { ...@@ -302,20 +302,20 @@ public abstract class Prepared {
* Print information about the statement executed if info trace level is * Print information about the statement executed if info trace level is
* enabled. * enabled.
* *
* @param startTime_nanos when the statement was started * @param startTimeNanos when the statement was started
* @param rowCount the query or update row count * @param rowCount the query or update row count
*/ */
void trace(long startTime_nanos, int rowCount) { void trace(long startTimeNanos, int rowCount) {
if (session.getTrace().isInfoEnabled() && startTime_nanos > 0) { if (session.getTrace().isInfoEnabled() && startTimeNanos > 0) {
long deltaTime_nanos = System.nanoTime() - startTime_nanos; long deltaTimeNanos = System.nanoTime() - startTimeNanos;
String params = Trace.formatParams(parameters); String params = Trace.formatParams(parameters);
session.getTrace().infoSQL(sqlStatement, params, rowCount, deltaTime_nanos / 1000 / 1000); session.getTrace().infoSQL(sqlStatement, params, rowCount, deltaTimeNanos / 1000 / 1000);
} }
// startTime_nanos can be zero for the command that actually turns on statistics // startTime_nanos can be zero for the command that actually turns on statistics
if (session.getDatabase().getQueryStatistics() && startTime_nanos != 0) { if (session.getDatabase().getQueryStatistics() && startTimeNanos != 0) {
long deltaTime_nanos = System.nanoTime() - startTime_nanos; long deltaTimeNanos = System.nanoTime() - startTimeNanos;
session.getDatabase().getQueryStatisticsData(). session.getDatabase().getQueryStatisticsData().
update(toString(), deltaTime_nanos, rowCount); update(toString(), deltaTimeNanos, rowCount);
} }
} }
......
...@@ -54,11 +54,11 @@ public class QueryStatisticsData { ...@@ -54,11 +54,11 @@ public class QueryStatisticsData {
* Update query statistics. * Update query statistics.
* *
* @param sqlStatement the statement being executed * @param sqlStatement the statement being executed
* @param executionTime_nanos the time in nanoseconds the query/update took to * @param executionTimeNanos the time in nanoseconds the query/update took to
* execute * execute
* @param rowCount the query or update row count * @param rowCount the query or update row count
*/ */
public synchronized void update(String sqlStatement, long executionTime_nanos, public synchronized void update(String sqlStatement, long executionTimeNanos,
int rowCount) { int rowCount) {
QueryEntry entry = map.get(sqlStatement); QueryEntry entry = map.get(sqlStatement);
if (entry == null) { if (entry == null) {
...@@ -66,7 +66,7 @@ public class QueryStatisticsData { ...@@ -66,7 +66,7 @@ public class QueryStatisticsData {
entry.sqlStatement = sqlStatement; entry.sqlStatement = sqlStatement;
map.put(sqlStatement, entry); map.put(sqlStatement, entry);
} }
entry.update(executionTime_nanos, rowCount); entry.update(executionTimeNanos, rowCount);
// Age-out the oldest entries if the map gets too big. // Age-out the oldest entries if the map gets too big.
// Test against 1.5 x max-size so we don't do this too often // Test against 1.5 x max-size so we don't do this too often
...@@ -114,17 +114,17 @@ public class QueryStatisticsData { ...@@ -114,17 +114,17 @@ public class QueryStatisticsData {
/** /**
* The minimum execution time, in nanoseconds. * The minimum execution time, in nanoseconds.
*/ */
public long executionTimeMin_nanos; public long executionTimeMinNanos;
/** /**
* The maximum execution time, in nanoseconds. * The maximum execution time, in nanoseconds.
*/ */
public long executionTimeMax_nanos; public long executionTimeMaxNanos;
/** /**
* The total execution time. * The total execution time.
*/ */
public long executionTimeCumulative_nanos; public long executionTimeCumulativeNanos;
/** /**
* The minimum number of rows. * The minimum number of rows.
...@@ -144,7 +144,7 @@ public class QueryStatisticsData { ...@@ -144,7 +144,7 @@ public class QueryStatisticsData {
/** /**
* The mean execution time. * The mean execution time.
*/ */
public double executionTimeMean_nanos; public double executionTimeMeanNanos;
/** /**
* The mean number of rows. * The mean number of rows.
...@@ -155,19 +155,19 @@ public class QueryStatisticsData { ...@@ -155,19 +155,19 @@ public class QueryStatisticsData {
// http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance // http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
// http://www.johndcook.com/standard_deviation.html // http://www.johndcook.com/standard_deviation.html
private double executionTimeM2_nanos; private double executionTimeM2Nanos;
private double rowCountM2; private double rowCountM2;
/** /**
* Update the statistics entry. * Update the statistics entry.
* *
* @param time_nanos the execution time in nanos * @param timeNanos the execution time in nanos
* @param rows the number of rows * @param rows the number of rows
*/ */
void update(long time_nanos, int rows) { void update(long timeNanos, int rows) {
count++; count++;
executionTimeMin_nanos = Math.min(time_nanos, executionTimeMin_nanos); executionTimeMinNanos = Math.min(timeNanos, executionTimeMinNanos);
executionTimeMax_nanos = Math.max(time_nanos, executionTimeMax_nanos); executionTimeMaxNanos = Math.max(timeNanos, executionTimeMaxNanos);
rowCountMin = Math.min(rows, rowCountMin); rowCountMin = Math.min(rows, rowCountMin);
rowCountMax = Math.max(rows, rowCountMax); rowCountMax = Math.max(rows, rowCountMax);
...@@ -175,18 +175,18 @@ public class QueryStatisticsData { ...@@ -175,18 +175,18 @@ public class QueryStatisticsData {
rowCountMean += rowDelta / count; rowCountMean += rowDelta / count;
rowCountM2 += rowDelta * (rows - rowCountMean); rowCountM2 += rowDelta * (rows - rowCountMean);
double timeDelta = time_nanos - executionTimeMean_nanos; double timeDelta = timeNanos - executionTimeMeanNanos;
executionTimeMean_nanos += timeDelta / count; executionTimeMeanNanos += timeDelta / count;
executionTimeM2_nanos += timeDelta * (time_nanos - executionTimeMean_nanos); executionTimeM2Nanos += timeDelta * (timeNanos - executionTimeMeanNanos);
executionTimeCumulative_nanos += time_nanos; executionTimeCumulativeNanos += timeNanos;
rowCountCumulative += rows; rowCountCumulative += rows;
lastUpdateTime = System.currentTimeMillis(); lastUpdateTime = System.currentTimeMillis();
} }
public double getExecutionTimeStandardDeviation() { public double getExecutionTimeStandardDeviation() {
// population standard deviation // population standard deviation
return Math.sqrt(executionTimeM2_nanos / count); return Math.sqrt(executionTimeM2Nanos / count);
} }
public double getRowCountStandardDeviation() { public double getRowCountStandardDeviation() {
......
...@@ -78,7 +78,7 @@ public class Session extends SessionWithState { ...@@ -78,7 +78,7 @@ public class Session extends SessionWithState {
private int lockTimeout; private int lockTimeout;
private Value lastIdentity = ValueLong.get(0); private Value lastIdentity = ValueLong.get(0);
private Value lastScopeIdentity = ValueLong.get(0); private Value lastScopeIdentity = ValueLong.get(0);
private Value lastTriggerIdentity = null; private Value lastTriggerIdentity;
private int firstUncommittedLog = Session.LOG_WRITTEN; private int firstUncommittedLog = Session.LOG_WRITTEN;
private int firstUncommittedPos = Session.LOG_WRITTEN; private int firstUncommittedPos = Session.LOG_WRITTEN;
private HashMap<String, Savepoint> savepoints; private HashMap<String, Savepoint> savepoints;
......
...@@ -8,7 +8,6 @@ package org.h2.engine; ...@@ -8,7 +8,6 @@ package org.h2.engine;
import java.io.Closeable; import java.io.Closeable;
import java.util.ArrayList; import java.util.ArrayList;
import org.h2.command.CommandInterface; import org.h2.command.CommandInterface;
import org.h2.jdbc.JdbcConnection;
import org.h2.message.Trace; import org.h2.message.Trace;
import org.h2.store.DataHandler; import org.h2.store.DataHandler;
import org.h2.value.Value; import org.h2.value.Value;
......
...@@ -7,7 +7,6 @@ package org.h2.index; ...@@ -7,7 +7,6 @@ package org.h2.index;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import org.h2.engine.Constants;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.mvstore.MVStore; import org.h2.mvstore.MVStore;
...@@ -187,7 +186,7 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex { ...@@ -187,7 +186,7 @@ public class SpatialTreeIndex extends BaseIndex implements SpatialIndex {
*/ */
public static long getCostRangeIndex(int[] masks, long rowCount, Column[] columns) { public static long getCostRangeIndex(int[] masks, long rowCount, Column[] columns) {
// Never use spatial tree index without spatial filter // Never use spatial tree index without spatial filter
if(columns.length == 0) { if (columns.length == 0) {
return Long.MAX_VALUE; return Long.MAX_VALUE;
} }
for (Column column : columns) { for (Column column : columns) {
......
...@@ -37,16 +37,13 @@ import org.h2.api.ErrorCode; ...@@ -37,16 +37,13 @@ import org.h2.api.ErrorCode;
import org.h2.command.CommandInterface; import org.h2.command.CommandInterface;
import org.h2.engine.ConnectionInfo; import org.h2.engine.ConnectionInfo;
import org.h2.engine.Constants; import org.h2.engine.Constants;
import org.h2.engine.Database;
import org.h2.engine.Mode; import org.h2.engine.Mode;
import org.h2.engine.Session;
import org.h2.engine.SessionInterface; import org.h2.engine.SessionInterface;
import org.h2.engine.SessionRemote; import org.h2.engine.SessionRemote;
import org.h2.engine.SysProperties; import org.h2.engine.SysProperties;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.message.TraceObject; import org.h2.message.TraceObject;
import org.h2.result.ResultInterface; import org.h2.result.ResultInterface;
import org.h2.schema.Schema;
import org.h2.util.CloseWatcher; import org.h2.util.CloseWatcher;
import org.h2.util.JdbcUtils; import org.h2.util.JdbcUtils;
import org.h2.util.Utils; import org.h2.util.Utils;
......
...@@ -1834,13 +1834,13 @@ public class MetaTable extends Table { ...@@ -1834,13 +1834,13 @@ public class MetaTable extends Table {
// EXECUTION_COUNT // EXECUTION_COUNT
"" + entry.count, "" + entry.count,
// MIN_EXECUTION_TIME // MIN_EXECUTION_TIME
"" + entry.executionTimeMin_nanos / 1000d / 1000, "" + entry.executionTimeMinNanos / 1000d / 1000,
// MAX_EXECUTION_TIME // MAX_EXECUTION_TIME
"" + entry.executionTimeMax_nanos / 1000d / 1000, "" + entry.executionTimeMaxNanos / 1000d / 1000,
// CUMULATIVE_EXECUTION_TIME // CUMULATIVE_EXECUTION_TIME
"" + entry.executionTimeCumulative_nanos / 1000d / 1000, "" + entry.executionTimeCumulativeNanos / 1000d / 1000,
// AVERAGE_EXECUTION_TIME // AVERAGE_EXECUTION_TIME
"" + entry.executionTimeMean_nanos / 1000d / 1000, "" + entry.executionTimeMeanNanos / 1000d / 1000,
// STD_DEV_EXECUTION_TIME // STD_DEV_EXECUTION_TIME
"" + entry.getExecutionTimeStandardDeviation() / 1000d / 1000, "" + entry.getExecutionTimeStandardDeviation() / 1000d / 1000,
// MIN_ROW_COUNT // MIN_ROW_COUNT
......
...@@ -914,8 +914,7 @@ public abstract class Value { ...@@ -914,8 +914,7 @@ public abstract class Value {
if (object instanceof java.util.UUID) { if (object instanceof java.util.UUID) {
java.util.UUID uuid = (java.util.UUID) object; java.util.UUID uuid = (java.util.UUID) object;
return ValueUuid.get(uuid.getMostSignificantBits(), uuid.getLeastSignificantBits()); return ValueUuid.get(uuid.getMostSignificantBits(), uuid.getLeastSignificantBits());
} } else {
else {
throw DbException.get(ErrorCode.DATA_CONVERSION_ERROR_1, getString()); throw DbException.get(ErrorCode.DATA_CONVERSION_ERROR_1, getString());
} }
case TIMESTAMP_TZ: case TIMESTAMP_TZ:
......
...@@ -294,14 +294,14 @@ public class ValueTimestampTimeZone extends Value { ...@@ -294,14 +294,14 @@ public class ValueTimestampTimeZone extends Value {
// even if the DST database changes. // even if the DST database changes.
// convert to minutes and add timezone offset // convert to minutes and add timezone offset
long a = DateTimeUtils.convertDateValueToMillis(TimeZone.getTimeZone("UTC"), dateValue) / ( 1000L * 60L ); long a = DateTimeUtils.convertDateValueToMillis(TimeZone.getTimeZone("UTC"), dateValue) / (1000L * 60L);
long ma = timeNanos / ( 1000L * 1000L * 1000L * 60L ); long ma = timeNanos / (1000L * 1000L * 1000L * 60L);
a += ma; a += ma;
a -= timeZoneOffsetMins; a -= timeZoneOffsetMins;
// convert to minutes and add timezone offset // convert to minutes and add timezone offset
long b = DateTimeUtils.convertDateValueToMillis(TimeZone.getTimeZone("UTC"), t.dateValue) / ( 1000L * 60L ); long b = DateTimeUtils.convertDateValueToMillis(TimeZone.getTimeZone("UTC"), t.dateValue) / (1000L * 60L);
long mb = t.timeNanos / ( 1000L * 1000L * 1000L * 60L ); long mb = t.timeNanos / (1000L * 1000L * 1000L * 60L);
b += mb; b += mb;
b -= t.timeZoneOffsetMins; b -= t.timeZoneOffsetMins;
...@@ -311,8 +311,8 @@ public class ValueTimestampTimeZone extends Value { ...@@ -311,8 +311,8 @@ public class ValueTimestampTimeZone extends Value {
return c; return c;
} }
// compare time // compare time
long na = timeNanos - ( ma * 1000L * 1000L * 1000L * 60L ); long na = timeNanos - (ma * 1000L * 1000L * 1000L * 60L);
long nb = t.timeNanos - ( mb * 1000L * 1000L * 1000L * 60L ); long nb = t.timeNanos - (mb * 1000L * 1000L * 1000L * 60L);
return MathUtils.compareLong(na, nb); return MathUtils.compareLong(na, nb);
} }
......
...@@ -53,6 +53,7 @@ import org.h2.test.db.TestPowerOff; ...@@ -53,6 +53,7 @@ import org.h2.test.db.TestPowerOff;
import org.h2.test.db.TestQueryCache; import org.h2.test.db.TestQueryCache;
import org.h2.test.db.TestReadOnly; import org.h2.test.db.TestReadOnly;
import org.h2.test.db.TestRecursiveQueries; import org.h2.test.db.TestRecursiveQueries;
import org.h2.test.db.TestReplace;
import org.h2.test.db.TestRights; import org.h2.test.db.TestRights;
import org.h2.test.db.TestRowFactory; import org.h2.test.db.TestRowFactory;
import org.h2.test.db.TestRunscript; import org.h2.test.db.TestRunscript;
...@@ -717,6 +718,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1` ...@@ -717,6 +718,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
addTest(new TestView()); addTest(new TestView());
addTest(new TestViewAlterTable()); addTest(new TestViewAlterTable());
addTest(new TestViewDropView()); addTest(new TestViewDropView());
addTest(new TestReplace());
// jaqu // jaqu
addTest(new AliasMapTest()); addTest(new AliasMapTest());
......
...@@ -171,8 +171,7 @@ public class TestCompatibilityOracle extends TestBase { ...@@ -171,8 +171,7 @@ public class TestCompatibilityOracle extends TestBase {
try { try {
stat.executeQuery("SELECT * FROM A WHERE ID IN ()"); stat.executeQuery("SELECT * FROM A WHERE ID IN ()");
fail(); fail();
} } catch (SQLException e) {
catch (SQLException e) {
} finally { } finally {
conn.close(); conn.close();
} }
......
...@@ -1294,7 +1294,7 @@ public class TestFunctions extends TestBase implements AggregateFunction { ...@@ -1294,7 +1294,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
} }
try { try {
ToDateParser.toDate("1-DEC-0000","DD-MON-RRRR"); ToDateParser.toDate("1-DEC-0000", "DD-MON-RRRR");
fail("Oracle to_date should reject year 0 (ORA-01841)"); fail("Oracle to_date should reject year 0 (ORA-01841)");
} catch (Exception e) { } } catch (Exception e) { }
} }
...@@ -2016,10 +2016,11 @@ public class TestFunctions extends TestBase implements AggregateFunction { ...@@ -2016,10 +2016,11 @@ public class TestFunctions extends TestBase implements AggregateFunction {
final String formatted; final String formatted;
try (final ResultSet rs = stat.executeQuery("select to_char(current_timestamp(9), 'YYYY MM DD HH24 MI SS FF3') from dual")) { final ResultSet rs = stat.executeQuery(
rs.next(); "select to_char(current_timestamp(9), 'YYYY MM DD HH24 MI SS FF3') from dual");
formatted = rs.getString(1); rs.next();
} formatted = rs.getString(1);
rs.close();
Date after = new Date(); Date after = new Date();
...@@ -2036,19 +2037,19 @@ public class TestFunctions extends TestBase implements AggregateFunction { ...@@ -2036,19 +2037,19 @@ public class TestFunctions extends TestBase implements AggregateFunction {
conn.setAutoCommit(false); conn.setAutoCommit(false);
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
final Timestamp first; Timestamp first;
try (final ResultSet rs = stat.executeQuery("select CURRENT_TIMESTAMP from DUAL")) { ResultSet rs = stat.executeQuery("select CURRENT_TIMESTAMP from DUAL");
rs.next(); rs.next();
first = rs.getTimestamp(1); first = rs.getTimestamp(1);
} rs.close();
Thread.sleep(1); Thread.sleep(1);
final Timestamp second; Timestamp second;
try (final ResultSet rs = stat.executeQuery("select CURRENT_TIMESTAMP from DUAL")) { rs = stat.executeQuery("select CURRENT_TIMESTAMP from DUAL");
rs.next(); rs.next();
second = rs.getTimestamp(1); second = rs.getTimestamp(1);
} rs.close();
assertEquals(first, second); assertEquals(first, second);
} }
...@@ -2059,19 +2060,19 @@ public class TestFunctions extends TestBase implements AggregateFunction { ...@@ -2059,19 +2060,19 @@ public class TestFunctions extends TestBase implements AggregateFunction {
conn.setAutoCommit(true); conn.setAutoCommit(true);
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
final Timestamp first; Timestamp first;
try (final ResultSet rs = stat.executeQuery("select CURRENT_TIMESTAMP from DUAL")) { ResultSet rs = stat.executeQuery("select CURRENT_TIMESTAMP from DUAL");
rs.next(); rs.next();
first = rs.getTimestamp(1); first = rs.getTimestamp(1);
} rs.close();
Thread.sleep(1); Thread.sleep(1);
final Timestamp second; Timestamp second;
try (final ResultSet rs = stat.executeQuery("select CURRENT_TIMESTAMP from DUAL")) { rs = stat.executeQuery("select CURRENT_TIMESTAMP from DUAL");
rs.next(); rs.next();
second = rs.getTimestamp(1); second = rs.getTimestamp(1);
} rs.close();
assertTrue(second.after(first)); assertTrue(second.after(first));
} }
......
...@@ -329,6 +329,9 @@ public class TestTriggersConstraints extends TestBase implements Trigger { ...@@ -329,6 +329,9 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
} }
/**
*
*/
public static class TestViewGeneratedKeys implements Trigger { public static class TestViewGeneratedKeys implements Trigger {
PreparedStatement prepInsert; PreparedStatement prepInsert;
......
...@@ -57,7 +57,7 @@ public class UpdateTest extends TestBase { ...@@ -57,7 +57,7 @@ public class UpdateTest extends TestBase {
Product p2 = new Product(); Product p2 = new Product();
Product pChang2 = db.from(p2).where(p2.productName).is("Chang") Product pChang2 = db.from(p2).where(p2.productName).is("Chang")
.selectFirst(); .selectFirst();
assertEquals((Double)19.5, pChang2.unitPrice); assertEquals((Double) 19.5, pChang2.unitPrice);
assertEquals(16, pChang2.unitsInStock.intValue()); assertEquals(16, pChang2.unitsInStock.intValue());
// undo update // undo update
...@@ -95,7 +95,7 @@ public class UpdateTest extends TestBase { ...@@ -95,7 +95,7 @@ public class UpdateTest extends TestBase {
Product p2 = new Product(); Product p2 = new Product();
Product pChang2 = db.from(p2).where(p2.productName).is("Chang") Product pChang2 = db.from(p2).where(p2.productName).is("Chang")
.selectFirst(); .selectFirst();
assertEquals((Double)19.5, pChang2.unitPrice); assertEquals((Double) 19.5, pChang2.unitPrice);
assertEquals(16, pChang2.unitsInStock.intValue()); assertEquals(16, pChang2.unitsInStock.intValue());
// undo update // undo update
...@@ -136,7 +136,7 @@ public class UpdateTest extends TestBase { ...@@ -136,7 +136,7 @@ public class UpdateTest extends TestBase {
// confirm the data was properly updated // confirm the data was properly updated
Product revised = db.from(p).where(p.productId).is(1).selectFirst(); Product revised = db.from(p).where(p.productId).is(1).selectFirst();
assertEquals("updated", revised.productName); assertEquals("updated", revised.productName);
assertEquals((Double)(original.unitPrice + 3.14), revised.unitPrice); assertEquals((Double) (original.unitPrice + 3.14), revised.unitPrice);
assertEquals(original.unitsInStock + 2, revised.unitsInStock.intValue()); assertEquals(original.unitsInStock + 2, revised.unitsInStock.intValue());
// restore the data // restore the data
......
...@@ -31,7 +31,6 @@ public class TestBenchmark extends TestBase { ...@@ -31,7 +31,6 @@ public class TestBenchmark extends TestBase {
@Override @Override
public void test() throws Exception { public void test() throws Exception {
;
// TODO this test is currently disabled // TODO this test is currently disabled
test(true); test(true);
......
...@@ -67,7 +67,7 @@ public class TestStreamStore extends TestBase { ...@@ -67,7 +67,7 @@ public class TestStreamStore extends TestBase {
if (max == -1) { if (max == -1) {
assertTrue(map.isEmpty()); assertTrue(map.isEmpty());
} else { } else {
assertEquals(map.lastKey(), (Long)max); assertEquals(map.lastKey(), (Long) max);
} }
} }
} }
......
...@@ -5,10 +5,8 @@ ...@@ -5,10 +5,8 @@
*/ */
package org.h2.test.unit; package org.h2.test.unit;
import java.math.BigDecimal;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DatabaseMetaData; import java.sql.DatabaseMetaData;
import java.sql.Date;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.ParameterMetaData; import java.sql.ParameterMetaData;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
......
...@@ -87,24 +87,24 @@ public class TestTimeStampWithTimeZone extends TestBase { ...@@ -87,24 +87,24 @@ public class TestTimeStampWithTimeZone extends TestBase {
} }
private void test2() { private void test2() {
ValueTimestampTimeZone a = ValueTimestampTimeZone.parse("1970-01-01 12:00:00.00+00:15"); ValueTimestampTimeZone a = ValueTimestampTimeZone.parse("1970-01-01 12:00:00.00+00:15");
ValueTimestampTimeZone b = ValueTimestampTimeZone.parse("1970-01-01 12:00:01.00+01:15"); ValueTimestampTimeZone b = ValueTimestampTimeZone.parse("1970-01-01 12:00:01.00+01:15");
int c= a.compareTo(b, null); int c = a.compareTo(b, null);
assertEquals(c, 1); assertEquals(c, 1);
} }
private void test3() { private void test3() {
ValueTimestampTimeZone a = ValueTimestampTimeZone.parse("1970-01-02 00:00:02.00+01:15"); ValueTimestampTimeZone a = ValueTimestampTimeZone.parse("1970-01-02 00:00:02.00+01:15");
ValueTimestampTimeZone b = ValueTimestampTimeZone.parse("1970-01-01 23:00:01.00+00:15"); ValueTimestampTimeZone b = ValueTimestampTimeZone.parse("1970-01-01 23:00:01.00+00:15");
int c= a.compareTo(b, null); int c = a.compareTo(b, null);
assertEquals(c, 1); assertEquals(c, 1);
} }
private void test4() { private void test4() {
ValueTimestampTimeZone a = ValueTimestampTimeZone.parse("1970-01-02 00:00:01.00+01:15"); ValueTimestampTimeZone a = ValueTimestampTimeZone.parse("1970-01-02 00:00:01.00+01:15");
ValueTimestampTimeZone b = ValueTimestampTimeZone.parse("1970-01-01 23:00:01.00+00:15"); ValueTimestampTimeZone b = ValueTimestampTimeZone.parse("1970-01-01 23:00:01.00+00:15");
int c= a.compareTo(b, null); int c = a.compareTo(b, null);
assertEquals(c, 0); assertEquals(c, 0);
} }
private void testOrder() throws SQLException { private void testOrder() throws SQLException {
......
...@@ -15,7 +15,6 @@ import java.sql.Timestamp; ...@@ -15,7 +15,6 @@ import java.sql.Timestamp;
import java.sql.Types; import java.sql.Types;
import java.util.UUID; import java.util.UUID;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.jdbc.JdbcSQLException;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.test.utils.AssertThrows; import org.h2.test.utils.AssertThrows;
...@@ -292,11 +291,11 @@ public class TestValue extends TestBase { ...@@ -292,11 +291,11 @@ public class TestValue extends TestBase {
ValueJavaObject valObj = ValueJavaObject.getNoCopy(origUUID, null, null); ValueJavaObject valObj = ValueJavaObject.getNoCopy(origUUID, null, null);
Value valUUID = valObj.convertTo(Value.UUID); Value valUUID = valObj.convertTo(Value.UUID);
assertTrue(valUUID instanceof ValueUuid); assertTrue(valUUID instanceof ValueUuid);
assertTrue((valUUID.getString().equals(uuidStr))); assertTrue(valUUID.getString().equals(uuidStr));
assertTrue(valUUID.getObject().equals(origUUID)); assertTrue(valUUID.getObject().equals(origUUID));
ValueJavaObject vo_string = ValueJavaObject.getNoCopy(new String("This is not a ValueUuid object"), null, null); ValueJavaObject voString = ValueJavaObject.getNoCopy(new String("This is not a ValueUuid object"), null, null);
assertThrows(DbException.class, vo_string).convertTo(Value.UUID); assertThrows(DbException.class, voString).convertTo(Value.UUID);
} }
private void testModulusDouble() { private void testModulusDouble() {
......
...@@ -111,7 +111,6 @@ public final class ImmutableArray<K> implements Iterable<K> { ...@@ -111,7 +111,6 @@ public final class ImmutableArray<K> implements Iterable<K> {
* @param array the data * @param array the data
* @return the new immutable array * @return the new immutable array
*/ */
@SuppressWarnings("unchecked")
public static <K> ImmutableArray<K> create(K... array) { public static <K> ImmutableArray<K> create(K... array) {
return new ImmutableArray<K>(array); return new ImmutableArray<K>(array);
} }
......
...@@ -151,7 +151,6 @@ public final class ImmutableArray2<K> implements Iterable<K> { ...@@ -151,7 +151,6 @@ public final class ImmutableArray2<K> implements Iterable<K> {
* @param array the data * @param array the data
* @return the new immutable array * @return the new immutable array
*/ */
@SuppressWarnings("unchecked")
public static <K> ImmutableArray2<K> create(K... array) { public static <K> ImmutableArray2<K> create(K... array) {
return new ImmutableArray2<K>(array, array.length); return new ImmutableArray2<K>(array, array.length);
} }
......
...@@ -84,7 +84,6 @@ public abstract class ImmutableArray3<K> implements Iterable<K> { ...@@ -84,7 +84,6 @@ public abstract class ImmutableArray3<K> implements Iterable<K> {
* @param array the data * @param array the data
* @return the new immutable array * @return the new immutable array
*/ */
@SuppressWarnings("unchecked")
public static <K> ImmutableArray3<K> create(K... array) { public static <K> ImmutableArray3<K> create(K... array) {
return new Plain<K>(array); return new Plain<K>(array);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论