提交 2585b4ea authored 作者: Thomas Mueller's avatar Thomas Mueller

Various smaller changes (FindBugs)

上级 8b1510e3
...@@ -177,7 +177,7 @@ public class CreateView extends SchemaCommand { ...@@ -177,7 +177,7 @@ public class CreateView extends SchemaCommand {
* work with TableViews directly because they become invalid when we drop * work with TableViews directly because they become invalid when we drop
* the parent view. * the parent view.
*/ */
private class DependentView { private static class DependentView {
String viewName; String viewName;
String createSql; String createSql;
String createForceSql; String createForceSql;
......
...@@ -64,7 +64,7 @@ public class Constants { ...@@ -64,7 +64,7 @@ public class Constants {
/** /**
* The minor version of this database. * The minor version of this database.
*/ */
public static final int VERSION_MINOR = 3; public static final int VERSION_MINOR = 2;
// Build.getLuceneVersion() uses an ugly hack to read this value // Build.getLuceneVersion() uses an ugly hack to read this value
/** /**
......
...@@ -102,8 +102,6 @@ public class Function extends Expression implements FunctionCall { ...@@ -102,8 +102,6 @@ public class Function extends Expression implements FunctionCall {
private static final HashMap<String, FunctionInfo> FUNCTIONS = New.hashMap(); private static final HashMap<String, FunctionInfo> FUNCTIONS = New.hashMap();
private static final HashMap<String, Integer> DATE_PART = New.hashMap(); private static final HashMap<String, Integer> DATE_PART = New.hashMap();
private static final SimpleDateFormat FORMAT_DAYNAME = new SimpleDateFormat("EEEE", Locale.ENGLISH);
private static final SimpleDateFormat FORMAT_MONTHNAME = new SimpleDateFormat("MMMM", Locale.ENGLISH);
private static final char[] SOUNDEX_INDEX = new char[128]; private static final char[] SOUNDEX_INDEX = new char[128];
protected Expression[] args; protected Expression[] args;
...@@ -605,9 +603,8 @@ public class Function extends Expression implements FunctionCall { ...@@ -605,9 +603,8 @@ public class Function extends Expression implements FunctionCall {
result = ValueString.get(StringUtils.xmlText(v0.getString())); result = ValueString.get(StringUtils.xmlText(v0.getString()));
break; break;
case DAY_NAME: { case DAY_NAME: {
synchronized (FORMAT_DAYNAME) { SimpleDateFormat dayName = new SimpleDateFormat("EEEE", Locale.ENGLISH);
result = ValueString.get(FORMAT_DAYNAME.format(v0.getDateNoCopy())); result = ValueString.get(dayName.format(v0.getDateNoCopy()));
}
break; break;
} }
case DAY_OF_MONTH: case DAY_OF_MONTH:
...@@ -629,9 +626,8 @@ public class Function extends Expression implements FunctionCall { ...@@ -629,9 +626,8 @@ public class Function extends Expression implements FunctionCall {
result = ValueInt.get(DateTimeUtils.getDatePart(v0.getDateNoCopy(), Calendar.MONTH)); result = ValueInt.get(DateTimeUtils.getDatePart(v0.getDateNoCopy(), Calendar.MONTH));
break; break;
case MONTH_NAME: { case MONTH_NAME: {
synchronized (FORMAT_MONTHNAME) { SimpleDateFormat monthName = new SimpleDateFormat("MMMM", Locale.ENGLISH);
result = ValueString.get(FORMAT_MONTHNAME.format(v0.getDateNoCopy())); result = ValueString.get(monthName.format(v0.getDateNoCopy()));
}
break; break;
} }
case QUARTER: case QUARTER:
......
...@@ -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", null);
} }
if (!escapeProcessing) { if (!escapeProcessing) {
return sql; return sql;
......
...@@ -8,6 +8,7 @@ package org.h2.server.web; ...@@ -8,6 +8,7 @@ package org.h2.server.web;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.Statement;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextEvent;
...@@ -70,7 +71,9 @@ public class DbStarter implements ServletContextListener { ...@@ -70,7 +71,9 @@ public class DbStarter implements ServletContextListener {
public void contextDestroyed(ServletContextEvent servletContextEvent) { public void contextDestroyed(ServletContextEvent servletContextEvent) {
try { try {
conn.createStatement().execute("SHUTDOWN"); Statement stat = conn.createStatement();
stat.execute("SHUTDOWN");
stat.close();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -276,7 +276,7 @@ public class FileLock implements Runnable { ...@@ -276,7 +276,7 @@ public class FileLock implements Runnable {
// lock file modified in the future - // lock file modified in the future -
// wait for a bit longer than usual // wait for a bit longer than usual
try { try {
Thread.sleep(2 * sleep); Thread.sleep(2 * (long) sleep);
} catch (Exception e) { } catch (Exception e) {
trace.debug(e, "sleep"); trace.debug(e, "sleep");
} }
......
...@@ -100,6 +100,7 @@ public class LobStorage { ...@@ -100,6 +100,7 @@ public class LobStorage {
rs = stat.executeQuery("SELECT MAX(BLOCK) FROM " + LOB_DATA); rs = stat.executeQuery("SELECT MAX(BLOCK) FROM " + LOB_DATA);
rs.next(); rs.next();
nextBlock = rs.getLong(1) + 1; nextBlock = rs.getLong(1) + 1;
stat.close();
} catch (SQLException e) { } catch (SQLException e) {
throw DbException.convert(e); throw DbException.convert(e);
} }
...@@ -602,11 +603,7 @@ public class LobStorage { ...@@ -602,11 +603,7 @@ public class LobStorage {
PreparedStatement prep = prepare("UPDATE " + LOBS + " SET TABLE = ? WHERE ID = ?"); PreparedStatement prep = prepare("UPDATE " + LOBS + " SET TABLE = ? WHERE ID = ?");
prep.setInt(1, table); prep.setInt(1, table);
prep.setLong(2, lobId); prep.setLong(2, lobId);
int updateCount = prep.executeUpdate(); prep.executeUpdate();
if (updateCount != 1) {
// can be zero when recovering
// throw DbException.throwInternalError("count: " + updateCount);
}
} catch (SQLException e) { } catch (SQLException e) {
throw DbException.convert(e); throw DbException.convert(e);
} }
......
...@@ -100,10 +100,9 @@ public abstract class Page extends CacheObject { ...@@ -100,10 +100,9 @@ public abstract class Page extends CacheObject {
* @return the (new) array * @return the (new) array
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public public static <T> T[] insert(T[] old, int oldSize, int pos, T x) {
static <T> T[] insert(T[] old, int oldSize, int pos, T x) {
T[] result; T[] result;
if (old != null && old.length > oldSize) { if (old.length > oldSize) {
result = old; result = old;
} else { } else {
// according to a test, this is as fast as "new Row[..]" // according to a test, this is as fast as "new Row[..]"
...@@ -112,7 +111,7 @@ public abstract class Page extends CacheObject { ...@@ -112,7 +111,7 @@ public abstract class Page extends CacheObject {
System.arraycopy(old, 0, result, 0, pos); System.arraycopy(old, 0, result, 0, pos);
} }
} }
if (old != null && oldSize - pos > 0) { if (oldSize - pos > 0) {
System.arraycopy(old, pos, result, pos + 1, oldSize - pos); System.arraycopy(old, pos, result, pos + 1, oldSize - pos);
} }
result[pos] = x; result[pos] = x;
......
...@@ -115,7 +115,7 @@ public class PageStreamTrunk extends Page { ...@@ -115,7 +115,7 @@ public class PageStreamTrunk extends Page {
if (index >= pageIds.length) { if (index >= pageIds.length) {
return -1; return -1;
} }
return pageIds[index++]; return pageIds[index];
} }
public void write() { public void write() {
......
...@@ -107,7 +107,9 @@ public class CreateCluster extends Tool { ...@@ -107,7 +107,9 @@ public class CreateCluster extends Tool {
boolean exists = true; boolean exists = true;
try { try {
connTarget = DriverManager.getConnection(urlTarget + ";IFEXISTS=TRUE;CLUSTER=" + Constants.CLUSTERING_ENABLED, user, password); connTarget = DriverManager.getConnection(urlTarget + ";IFEXISTS=TRUE;CLUSTER=" + Constants.CLUSTERING_ENABLED, user, password);
connTarget.createStatement().execute("DROP ALL OBJECTS DELETE FILES"); Statement stat = connTarget.createStatement();
stat.execute("DROP ALL OBJECTS DELETE FILES");
stat.close();
exists = false; exists = false;
connTarget.close(); connTarget.close();
} catch (SQLException e) { } catch (SQLException e) {
......
...@@ -86,7 +86,7 @@ public class Recover extends Tool implements DataHandler { ...@@ -86,7 +86,7 @@ public class Recover extends Tool implements DataHandler {
/** /**
* Statistic data * Statistic data
*/ */
class Stats { static class Stats {
/** /**
* The empty space in bytes in a data leaf pages. * The empty space in bytes in a data leaf pages.
......
...@@ -123,6 +123,7 @@ public class MathUtils { ...@@ -123,6 +123,7 @@ public class MathUtils {
} }
} catch (Exception e) { } catch (Exception e) {
// nanoTime not found, this is ok (only exists for JDK 1.5 and higher) // nanoTime not found, this is ok (only exists for JDK 1.5 and higher)
out.writeUTF(e.toString());
} }
// memory // memory
......
...@@ -36,6 +36,7 @@ public class Compact { ...@@ -36,6 +36,7 @@ public class Compact {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)"); stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR)");
stat.execute("INSERT INTO TEST VALUES(1, 'Hello'), (2, 'World');"); stat.execute("INSERT INTO TEST VALUES(1, 'Hello'), (2, 'World');");
stat.close();
conn.close(); conn.close();
System.out.println("Compacting..."); System.out.println("Compacting...");
compact("data", "test", "sa", ""); compact("data", "test", "sa", "");
......
...@@ -53,6 +53,8 @@ public class DirectInsert { ...@@ -53,6 +53,8 @@ public class DirectInsert {
prep.execute(); prep.execute();
} }
conn.commit(); conn.commit();
prep.close();
stat.close();
conn.close(); conn.close();
} }
...@@ -65,6 +67,7 @@ public class DirectInsert { ...@@ -65,6 +67,7 @@ public class DirectInsert {
stat.execute("CREATE TABLE TEST2 AS SELECT * FROM TEST"); stat.execute("CREATE TABLE TEST2 AS SELECT * FROM TEST");
System.out.printf("%.3f sec.\n", (System.currentTimeMillis() - time) / 1000.0); System.out.printf("%.3f sec.\n", (System.currentTimeMillis() - time) / 1000.0);
stat.execute("INSERT INTO TEST2 SELECT * FROM TEST2"); stat.execute("INSERT INTO TEST2 SELECT * FROM TEST2");
stat.close();
conn.close(); conn.close();
} }
......
...@@ -40,6 +40,7 @@ public class FileFunctions { ...@@ -40,6 +40,7 @@ public class FileFunctions {
rs.next(); rs.next();
String text = rs.getString(1); String text = rs.getString(1);
System.out.println("text: " + text); System.out.println("text: " + text);
stat.close();
conn.close(); conn.close();
} }
......
...@@ -51,14 +51,14 @@ public class Function { ...@@ -51,14 +51,14 @@ public class Function {
PreparedStatement prep; PreparedStatement prep;
prep = conn.prepareStatement("SELECT * FROM TABLE(X INT=?, O INT=?) J " + prep = conn.prepareStatement("SELECT * FROM TABLE(X INT=?, O INT=?) J " +
"INNER JOIN TEST T ON J.X=T.ID ORDER BY J.O"); "INNER JOIN TEST T ON J.X=T.ID ORDER BY J.O");
prep.setObject(1, prep.setObject(1, new Integer[] { 30, 20 });
new Integer[] { new Integer(30), new Integer(20) }); prep.setObject(2, new Integer[] { 1, 2 });
prep.setObject(2,
new Integer[] { new Integer(1), new Integer(2) });
rs = prep.executeQuery(); rs = prep.executeQuery();
while (rs.next()) { while (rs.next()) {
System.out.println(rs.getInt(1)); System.out.println(rs.getInt(1));
} }
prep.close();
rs.close();
// Using a custom function like table // Using a custom function like table
stat.execute("CREATE ALIAS MATRIX FOR \"org.h2.samples.Function.getMatrix\" "); stat.execute("CREATE ALIAS MATRIX FOR \"org.h2.samples.Function.getMatrix\" ");
...@@ -69,7 +69,8 @@ public class Function { ...@@ -69,7 +69,8 @@ public class Function {
while (rs.next()) { while (rs.next()) {
System.out.println(rs.getInt(1) + "/" + rs.getInt(2)); System.out.println(rs.getInt(1) + "/" + rs.getInt(2));
} }
prep.close();
stat.close();
conn.close(); conn.close();
} }
......
...@@ -69,7 +69,7 @@ public class FunctionMultiReturn { ...@@ -69,7 +69,7 @@ public class FunctionMultiReturn {
System.out.println("(r=" + r + " a=" + a + ") : (x=" + x + ", y=" + y + ")"); System.out.println("(r=" + r + " a=" + a + ") : (x=" + x + ", y=" + y + ")");
} }
rs = conn.createStatement().executeQuery("SELECT R, A, ARRAY_GET(E, 1), ARRAY_GET(E, 2) FROM (SELECT R, A, P2C_A(R, A) E FROM TEST)"); rs = stat.executeQuery("SELECT R, A, ARRAY_GET(E, 1), ARRAY_GET(E, 2) FROM (SELECT R, A, P2C_A(R, A) E FROM TEST)");
while (rs.next()) { while (rs.next()) {
double r = rs.getDouble(1); double r = rs.getDouble(1);
double a = rs.getDouble(2); double a = rs.getDouble(2);
...@@ -77,7 +77,9 @@ public class FunctionMultiReturn { ...@@ -77,7 +77,9 @@ public class FunctionMultiReturn {
double y = rs.getDouble(4); double y = rs.getDouble(4);
System.out.println("(r="+r+" a="+a+") : (x=" + x + ", y="+y+")"); System.out.println("(r="+r+" a="+a+") : (x=" + x + ", y="+y+")");
} }
rs.close();
prep.close();
conn.close(); conn.close();
} }
......
...@@ -41,6 +41,7 @@ public class HelloWorld { ...@@ -41,6 +41,7 @@ public class HelloWorld {
while (rs.next()) { while (rs.next()) {
System.out.println(rs.getString("name")); System.out.println(rs.getString("name"));
} }
stat.close();
conn.close(); conn.close();
} }
......
...@@ -42,6 +42,7 @@ public class InitDatabaseFromJar { ...@@ -42,6 +42,7 @@ public class InitDatabaseFromJar {
stat.execute("CREATE TABLE TEST(NAME VARCHAR)"); stat.execute("CREATE TABLE TEST(NAME VARCHAR)");
stat.execute("INSERT INTO TEST VALUES('Hello World')"); stat.execute("INSERT INTO TEST VALUES('Hello World')");
stat.execute("SCRIPT TO 'script.sql'"); stat.execute("SCRIPT TO 'script.sql'");
stat.close();
conn.close(); conn.close();
} }
...@@ -57,10 +58,13 @@ public class InitDatabaseFromJar { ...@@ -57,10 +58,13 @@ public class InitDatabaseFromJar {
+ getClass().getPackage().getName()); + getClass().getPackage().getName());
} else { } else {
RunScript.execute(conn, new InputStreamReader(in)); RunScript.execute(conn, new InputStreamReader(in));
ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM TEST"); Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery("SELECT * FROM TEST");
while (rs.next()) { while (rs.next()) {
System.out.println(rs.getString(1)); System.out.println(rs.getString(1));
} }
rs.close();
stat.close();
conn.close(); conn.close();
} }
} }
......
...@@ -212,6 +212,8 @@ public class SQLInjection { ...@@ -212,6 +212,8 @@ public class SQLInjection {
} else { } else {
System.out.println("Access denied!"); System.out.println("Access denied!");
} }
rs.close();
prep.close();
} }
/** /**
...@@ -250,6 +252,8 @@ public class SQLInjection { ...@@ -250,6 +252,8 @@ public class SQLInjection {
} else { } else {
System.out.println("Access denied!"); System.out.println("Access denied!");
} }
rs.close();
prep.close();
} catch (SQLException e) { } catch (SQLException e) {
System.out.println(e); System.out.println(e);
} }
...@@ -274,6 +278,8 @@ public class SQLInjection { ...@@ -274,6 +278,8 @@ public class SQLInjection {
} else { } else {
System.out.println("Access denied!"); System.out.println("Access denied!");
} }
rs.close();
prep.close();
} catch (Exception e) { } catch (Exception e) {
System.out.println(e); System.out.println(e);
} }
...@@ -364,9 +370,11 @@ public class SQLInjection { ...@@ -364,9 +370,11 @@ public class SQLInjection {
while (rs.next()) { while (rs.next()) {
System.out.println(rs.getString(1) + ": " + rs.getString(2)); System.out.println(rs.getString(1) + ": " + rs.getString(2));
} }
rs.close();
} catch (Exception e) { } catch (Exception e) {
System.out.println(e); System.out.println(e);
} }
prep.close();
} }
/** /**
...@@ -402,7 +410,10 @@ public class SQLInjection { ...@@ -402,7 +410,10 @@ public class SQLInjection {
System.out.println("salt: " + rs.getString("SALT")); System.out.println("salt: " + rs.getString("SALT"));
System.out.println("hash: " + rs.getString("HASH")); System.out.println("hash: " + rs.getString("HASH"));
} }
rs.close();
prep.close();
stat.execute("SET ALLOW_LITERALS ALL"); stat.execute("SET ALLOW_LITERALS ALL");
stat.close();
} }
/** /**
......
...@@ -56,11 +56,15 @@ public class SecurePassword { ...@@ -56,11 +56,15 @@ public class SecurePassword {
prep = conn.prepareStatement("insert into account(name) values(?)"); prep = conn.prepareStatement("insert into account(name) values(?)");
prep.setString(1, "Joe"); prep.setString(1, "Joe");
prep.execute(); prep.execute();
prep.close();
prep = conn.prepareStatement( prep = conn.prepareStatement(
"update account set hash=hash('SHA256', stringtoutf8(salt||?), 10) where name=?"); "update account set hash=hash('SHA256', stringtoutf8(salt||?), 10) where name=?");
prep.setString(1, "secret"); prep.setString(1, "secret");
prep.setString(2, "Joe"); prep.setString(2, "Joe");
prep.execute(); prep.execute();
prep.close();
prep = conn.prepareStatement( prep = conn.prepareStatement(
"select * from account where name=? and hash=hash('SHA256', stringtoutf8(salt||?), 10)"); "select * from account where name=? and hash=hash('SHA256', stringtoutf8(salt||?), 10)");
prep.setString(1, "Joe"); prep.setString(1, "Joe");
...@@ -69,6 +73,9 @@ public class SecurePassword { ...@@ -69,6 +73,9 @@ public class SecurePassword {
while (rs.next()) { while (rs.next()) {
System.out.println(rs.getString("name")); System.out.println(rs.getString("name"));
} }
rs.close();
prep.close();
stat.close();
conn.close(); conn.close();
} }
......
...@@ -80,6 +80,8 @@ public class ShowProgress implements DatabaseEventListener { ...@@ -80,6 +80,8 @@ public class ShowProgress implements DatabaseEventListener {
conn = DriverManager.getConnection("jdbc:h2:test;DATABASE_EVENT_LISTENER='" + getClass().getName() + "'", "sa", ""); conn = DriverManager.getConnection("jdbc:h2:test;DATABASE_EVENT_LISTENER='" + getClass().getName() + "'", "sa", "");
time = System.currentTimeMillis() - time; time = System.currentTimeMillis() - time;
System.out.println("Done after " + time + " ms"); System.out.println("Done after " + time + " ms");
prep.close();
stat.close();
conn.close(); conn.close();
} }
......
...@@ -49,6 +49,7 @@ public class TriggerPassData implements Trigger { ...@@ -49,6 +49,7 @@ public class TriggerPassData implements Trigger {
stat.execute("INSERT INTO TEST VALUES(1)"); stat.execute("INSERT INTO TEST VALUES(1)");
stat.execute("CALL TRIGGER_SET('T1', 'World')"); stat.execute("CALL TRIGGER_SET('T1', 'World')");
stat.execute("INSERT INTO TEST VALUES(2)"); stat.execute("INSERT INTO TEST VALUES(2)");
stat.close();
conn.close(); conn.close();
} }
......
...@@ -47,6 +47,8 @@ public class TriggerSample { ...@@ -47,6 +47,8 @@ public class TriggerSample {
rs = stat.executeQuery("SELECT AMOUNT FROM INVOICE_SUM"); rs = stat.executeQuery("SELECT AMOUNT FROM INVOICE_SUM");
rs.next(); rs.next();
System.out.println("The sum is " + rs.getBigDecimal(1)); System.out.println("The sum is " + rs.getBigDecimal(1));
rs.close();
stat.close();
conn.close(); conn.close();
} }
......
...@@ -1150,7 +1150,7 @@ public abstract class TestBase { ...@@ -1150,7 +1150,7 @@ public abstract class TestBase {
*/ */
protected void assertEquals(Integer expected, Integer actual) { protected void assertEquals(Integer expected, Integer actual) {
if (expected == null || actual == null) { if (expected == null || actual == null) {
assertTrue(expected == actual); assertTrue(expected == null && actual == null);
} else { } else {
assertEquals(expected.intValue(), actual.intValue()); assertEquals(expected.intValue(), actual.intValue());
} }
...@@ -1247,8 +1247,6 @@ public abstract class TestBase { ...@@ -1247,8 +1247,6 @@ public abstract class TestBase {
} }
// silly code - makes sure there are no warnings // silly code - makes sure there are no warnings
reserve[0] = reserve[1]; reserve[0] = reserve[1];
// actually it is anyway garbage collected
reserve = null;
} }
/** /**
......
...@@ -404,7 +404,7 @@ class Database { ...@@ -404,7 +404,7 @@ class Database {
*/ */
void log(String action, String scale, int value) { void log(String action, String scale, int value) {
if (test.collect) { if (test.collect) {
results.add(new Object[] { action, scale, new Integer(value) }); results.add(new Object[] { action, scale, Integer.valueOf(value) });
} }
} }
......
...@@ -216,7 +216,7 @@ public class TestCluster extends TestBase { ...@@ -216,7 +216,7 @@ public class TestCluster extends TestBase {
// try to connect in standalone mode - should fail // try to connect in standalone mode - should fail
try { try {
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:"+port1+"/test", user, password); DriverManager.getConnection("jdbc:h2:tcp://localhost:"+port1+"/test", user, password);
fail("should not be able to connect in standalone mode"); fail("should not be able to connect in standalone mode");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
......
...@@ -389,7 +389,7 @@ public class TestFullText extends TestBase { ...@@ -389,7 +389,7 @@ public class TestFullText extends TestBase {
conn = getConnection("fullText"); conn = getConnection("fullText");
stat = conn.createStatement(); stat = conn.createStatement();
rs = stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('World', 0, 0)"); stat.executeQuery("SELECT * FROM " + prefix + "SEARCH('World', 0, 0)");
stat.execute("CALL " + prefix + "DROP_ALL()"); stat.execute("CALL " + prefix + "DROP_ALL()");
......
...@@ -380,7 +380,7 @@ public class TestFunctions extends TestBase implements AggregateFunction { ...@@ -380,7 +380,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
assertEquals("Hello", rs.getString(2)); assertEquals("Hello", rs.getString(2));
assertFalse(rs.next()); assertFalse(rs.next());
rs = stat.executeQuery("CALL ADD_ROW(2, 'World')"); stat.executeQuery("CALL ADD_ROW(2, 'World')");
stat.execute("CREATE ALIAS SELECT_F FOR \"" + getClass().getName() + ".select\""); stat.execute("CREATE ALIAS SELECT_F FOR \"" + getClass().getName() + ".select\"");
rs = stat.executeQuery("CALL SELECT_F('SELECT * FROM TEST ORDER BY ID')"); rs = stat.executeQuery("CALL SELECT_F('SELECT * FROM TEST ORDER BY ID')");
...@@ -631,7 +631,7 @@ public class TestFunctions extends TestBase implements AggregateFunction { ...@@ -631,7 +631,7 @@ public class TestFunctions extends TestBase implements AggregateFunction {
* @return the test array * @return the test array
*/ */
public static Object[] getArray() { public static Object[] getArray() {
return new Object[] { new Integer(0), "Hello" }; return new Object[] { 0, "Hello" };
} }
/** /**
......
...@@ -496,8 +496,8 @@ public class TestOptimizations extends TestBase { ...@@ -496,8 +496,8 @@ public class TestOptimizations extends TestBase {
} else { } else {
int value = random.nextInt(); int value = random.nextInt();
stat.execute("insert into test values(" + i + ", " + value + ")"); stat.execute("insert into test values(" + i + ", " + value + ")");
map.put(new Integer(i), new Integer(value)); map.put(i, value);
set.add(new Integer(value)); set.add(value);
} }
break; break;
case 6: case 6:
......
...@@ -31,7 +31,8 @@ public class TestQueryCache extends TestBase { ...@@ -31,7 +31,8 @@ public class TestQueryCache extends TestBase {
Connection conn = getConnection("queryCache;QUERY_CACHE_SIZE=10"); Connection conn = getConnection("queryCache;QUERY_CACHE_SIZE=10");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("create table test(id int, name varchar) as select x, space(100) from system_range(1, 1000)"); stat.execute("create table test(id int, name varchar) as select x, space(100) from system_range(1, 1000)");
PreparedStatement prep = conn.prepareStatement("select count(*) from test t1, test t2"); PreparedStatement prep;
conn.prepareStatement("select count(*) from test t1, test t2");
long time; long time;
ResultSet rs; ResultSet rs;
long first = 0; long first = 0;
...@@ -42,7 +43,7 @@ public class TestQueryCache extends TestBase { ...@@ -42,7 +43,7 @@ public class TestQueryCache extends TestBase {
// stat.execute("drop table x"); // stat.execute("drop table x");
time = System.currentTimeMillis(); time = System.currentTimeMillis();
prep = conn.prepareStatement("select count(*) from test t1, test t2"); prep = conn.prepareStatement("select count(*) from test t1, test t2");
rs = prep.executeQuery(); prep.executeQuery();
rs = stat.executeQuery("select count(*) from test t1, test t2"); rs = stat.executeQuery("select count(*) from test t1, test t2");
rs.next(); rs.next();
int c = rs.getInt(1); int c = rs.getInt(1);
......
...@@ -29,7 +29,7 @@ public class TestRecursiveQueries extends TestBase { ...@@ -29,7 +29,7 @@ public class TestRecursiveQueries extends TestBase {
public void test() throws Exception { public void test() throws Exception {
deleteDb("recursiveQueries"); deleteDb("recursiveQueries");
Connection conn = getConnection("recursiveQueries"); Connection conn = getConnection("recursiveQueries");
Statement stat = conn.createStatement(); Statement stat;
PreparedStatement prep, prep2; PreparedStatement prep, prep2;
ResultSet rs; ResultSet rs;
......
...@@ -224,13 +224,13 @@ public class TestRights extends TestBase { ...@@ -224,13 +224,13 @@ public class TestRights extends TestBase {
conn.close(); conn.close();
try { try {
conn = getConnection("rights", "Test", getPassword("abc")); getConnection("rights", "Test", getPassword("abc"));
fail("mixed case user name"); fail("mixed case user name");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
} }
try { try {
conn = getConnection("rights", "TEST", getPassword("abc")); getConnection("rights", "TEST", getPassword("abc"));
fail("wrong password"); fail("wrong password");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
......
...@@ -146,7 +146,6 @@ public class TestTransaction extends TestBase { ...@@ -146,7 +146,6 @@ public class TestTransaction extends TestBase {
if (!config.memory) { if (!config.memory) {
conn.close(); conn.close();
conn = getConnection("transaction"); conn = getConnection("transaction");
stat = conn.createStatement();
} }
stat = conn.createStatement(); stat = conn.createStatement();
try { try {
...@@ -194,7 +193,6 @@ public class TestTransaction extends TestBase { ...@@ -194,7 +193,6 @@ public class TestTransaction extends TestBase {
if (!config.memory) { if (!config.memory) {
conn.close(); conn.close();
conn = getConnection("transaction"); conn = getConnection("transaction");
stat = conn.createStatement();
} }
stat = conn.createStatement(); stat = conn.createStatement();
try { try {
......
...@@ -56,7 +56,7 @@ public class UpdateTest extends TestBase { ...@@ -56,7 +56,7 @@ public class UpdateTest extends TestBase {
Product p2 = new Product(); Product p2 = new Product();
Product pChang2 = db.from(p2).where(p2.productName).is("Chang").selectFirst(); Product pChang2 = db.from(p2).where(p2.productName).is("Chang").selectFirst();
assertEquals(19.5, pChang2.unitPrice); assertEquals(19.5, pChang2.unitPrice);
assertEquals(new Integer(16), pChang2.unitsInStock); assertEquals(16, pChang2.unitsInStock.intValue());
// undo update // undo update
pChang.unitPrice = 19.0; pChang.unitPrice = 19.0;
...@@ -90,7 +90,7 @@ public class UpdateTest extends TestBase { ...@@ -90,7 +90,7 @@ public class UpdateTest extends TestBase {
Product p2 = new Product(); Product p2 = new Product();
Product pChang2 = db.from(p2).where(p2.productName).is("Chang").selectFirst(); Product pChang2 = db.from(p2).where(p2.productName).is("Chang").selectFirst();
assertEquals(19.5, pChang2.unitPrice); assertEquals(19.5, pChang2.unitPrice);
assertEquals(new Integer(16), pChang2.unitsInStock); assertEquals(16, pChang2.unitsInStock.intValue());
// undo update // undo update
pChang.unitPrice = 19.0; pChang.unitPrice = 19.0;
......
...@@ -400,12 +400,12 @@ public class TestPreparedStatement extends TestBase { ...@@ -400,12 +400,12 @@ public class TestPreparedStatement extends TestBase {
stat.execute("CREATE TABLE TEST(ID INT, DATA BINARY, JAVA OTHER)"); stat.execute("CREATE TABLE TEST(ID INT, DATA BINARY, JAVA OTHER)");
prep = conn.prepareStatement("INSERT INTO TEST VALUES(?, ?, ?)"); prep = conn.prepareStatement("INSERT INTO TEST VALUES(?, ?, ?)");
prep.setInt(1, 1); prep.setInt(1, 1);
prep.setObject(2, new Integer(11)); prep.setObject(2, 11);
prep.setObject(3, null); prep.setObject(3, null);
prep.execute(); prep.execute();
prep.setInt(1, 2); prep.setInt(1, 2);
prep.setObject(2, new Integer(101), Types.OTHER); prep.setObject(2, 101, Types.OTHER);
prep.setObject(3, new Integer(103), Types.OTHER); prep.setObject(3, 103, Types.OTHER);
prep.execute(); prep.execute();
PreparedStatement p2 = conn.prepareStatement("SELECT * FROM TEST ORDER BY ID"); PreparedStatement p2 = conn.prepareStatement("SELECT * FROM TEST ORDER BY ID");
ResultSet rs = p2.executeQuery(); ResultSet rs = p2.executeQuery();
...@@ -678,7 +678,7 @@ public class TestPreparedStatement extends TestBase { ...@@ -678,7 +678,7 @@ public class TestPreparedStatement extends TestBase {
// some databases don't allow calling setObject with null (no data type) // some databases don't allow calling setObject with null (no data type)
prep.executeUpdate(); prep.executeUpdate();
prep.setInt(1, 9); prep.setInt(1, 9);
prep.setObject(2, new Integer(-4), Types.VARCHAR); prep.setObject(2, -4, Types.VARCHAR);
prep.executeUpdate(); prep.executeUpdate();
prep.setInt(1, 10); prep.setInt(1, 10);
prep.setObject(2, "5", Types.INTEGER); prep.setObject(2, "5", Types.INTEGER);
...@@ -797,7 +797,7 @@ public class TestPreparedStatement extends TestBase { ...@@ -797,7 +797,7 @@ public class TestPreparedStatement extends TestBase {
assertTrue(rs.getObject(1).equals(new Boolean(true))); assertTrue(rs.getObject(1).equals(new Boolean(true)));
assertTrue(rs.getObject(2).equals("Abc")); assertTrue(rs.getObject(2).equals("Abc"));
assertTrue(rs.getObject(3).equals(new BigDecimal("10.2"))); assertTrue(rs.getObject(3).equals(new BigDecimal("10.2")));
assertTrue(rs.getObject(4).equals(new Byte((byte) 0xff))); assertTrue(rs.getObject(4).equals((byte) 0xff));
assertTrue(rs.getObject(5).equals(new Short(Short.MAX_VALUE))); assertTrue(rs.getObject(5).equals(new Short(Short.MAX_VALUE)));
assertTrue(rs.getObject(6).equals(new Integer(Integer.MIN_VALUE))); assertTrue(rs.getObject(6).equals(new Integer(Integer.MIN_VALUE)));
assertTrue(rs.getObject(7).equals(new Long(Long.MAX_VALUE))); assertTrue(rs.getObject(7).equals(new Long(Long.MAX_VALUE)));
...@@ -809,7 +809,7 @@ public class TestPreparedStatement extends TestBase { ...@@ -809,7 +809,7 @@ public class TestPreparedStatement extends TestBase {
assertTrue(rs.getObject(12).equals(java.sql.Timestamp.valueOf("2001-02-03 04:05:06.123456789"))); assertTrue(rs.getObject(12).equals(java.sql.Timestamp.valueOf("2001-02-03 04:05:06.123456789")));
assertTrue(rs.getObject(13).equals(java.sql.Timestamp.valueOf("2001-02-03 00:00:00"))); assertTrue(rs.getObject(13).equals(java.sql.Timestamp.valueOf("2001-02-03 00:00:00")));
assertEquals(new byte[] { 10, 20, 30 }, (byte[]) rs.getObject(14)); assertEquals(new byte[] { 10, 20, 30 }, (byte[]) rs.getObject(14));
assertTrue(rs.getObject(15).equals(new Character('a'))); assertTrue(rs.getObject(15).equals('a'));
assertTrue(rs.getObject(16).equals(java.sql.Date.valueOf("2001-01-02"))); assertTrue(rs.getObject(16).equals(java.sql.Date.valueOf("2001-01-02")));
assertTrue(rs.getObject(17) == null && rs.wasNull()); assertTrue(rs.getObject(17) == null && rs.wasNull());
assertTrue(rs.getObject(18).equals(new Double(3.725))); assertTrue(rs.getObject(18).equals(new Double(3.725)));
......
...@@ -1066,8 +1066,9 @@ public class TestResultSet extends TestBase { ...@@ -1066,8 +1066,9 @@ public class TestResultSet extends TestBase {
prep.setObject(2, new Object[] { new Integer(1), new Integer(2) }); prep.setObject(2, new Object[] { new Integer(1), new Integer(2) });
prep.execute(); prep.execute();
prep.setInt(1, 2); prep.setInt(1, 2);
prep.setObject(2, new Object[] { new Integer(11), new Integer(12) }); prep.setObject(2, new Object[] { 11, 12 });
prep.execute(); prep.execute();
prep.close();
rs = stat.executeQuery("SELECT * FROM TEST ORDER BY ID"); rs = stat.executeQuery("SELECT * FROM TEST ORDER BY ID");
rs.next(); rs.next();
assertEquals(1, rs.getInt(1)); assertEquals(1, rs.getInt(1));
......
...@@ -275,7 +275,7 @@ public class TestUpdatableResultSet extends TestBase { ...@@ -275,7 +275,7 @@ public class TestUpdatableResultSet extends TestBase {
rs.updateDouble("DB", 1.725); rs.updateDouble("DB", 1.725);
rs.updateFloat("R", (float) 2.5); rs.updateFloat("R", (float) 2.5);
rs.updateLong("L", Long.MAX_VALUE); rs.updateLong("L", Long.MAX_VALUE);
rs.updateObject("O_I", new Integer(10)); rs.updateObject("O_I", 10);
rs.updateShort("SH", Short.MIN_VALUE); rs.updateShort("SH", Short.MIN_VALUE);
// auml, ouml, uuml // auml, ouml, uuml
rs.updateCharacterStream("CL", new StringReader("\u00ef\u00f6\u00fc"), 0); rs.updateCharacterStream("CL", new StringReader("\u00ef\u00f6\u00fc"), 0);
......
...@@ -85,6 +85,7 @@ public class TestCrashAPI extends TestBase implements Runnable { ...@@ -85,6 +85,7 @@ public class TestCrashAPI extends TestBase implements Runnable {
try { try {
Thread.sleep(1000); Thread.sleep(1000);
} catch (InterruptedException e) { } catch (InterruptedException e) {
maxWait++;
// ignore // ignore
} }
} }
...@@ -409,17 +410,17 @@ public class TestCrashAPI extends TestBase implements Runnable { ...@@ -409,17 +410,17 @@ public class TestCrashAPI extends TestBase implements Runnable {
private Object getRandomParam(Class<?> type) { private Object getRandomParam(Class<?> type) {
if (type == int.class) { if (type == int.class) {
return new Integer(random.getRandomInt()); return random.getRandomInt();
} else if (type == byte.class) { } else if (type == byte.class) {
return new Byte((byte) random.getRandomInt()); return (byte) random.getRandomInt();
} else if (type == short.class) { } else if (type == short.class) {
return new Short((short) random.getRandomInt()); return (short) random.getRandomInt();
} else if (type == long.class) { } else if (type == long.class) {
return new Long(random.getRandomLong()); return random.getRandomLong();
} else if (type == float.class) { } else if (type == float.class) {
return new Float(random.getRandomDouble()); return (float) random.getRandomDouble();
} else if (type == boolean.class) { } else if (type == boolean.class) {
return new Boolean(random.nextBoolean()); return random.nextBoolean();
} else if (type == double.class) { } else if (type == double.class) {
return new Double(random.getRandomDouble()); return new Double(random.getRandomDouble());
} else if (type == String.class) { } else if (type == String.class) {
......
...@@ -141,7 +141,7 @@ public class TestJoin extends TestBase { ...@@ -141,7 +141,7 @@ public class TestJoin extends TestBase {
String sql = buff.toString(); String sql = buff.toString();
Object[] params = new Object[paramCount]; Object[] params = new Object[paramCount];
for (int j = 0; j < paramCount; j++) { for (int j = 0; j < paramCount; j++) {
params[j] = random.nextInt(4) == 1 ? null : new Integer(random.nextInt(10) - 3); params[j] = random.nextInt(4) == 1 ? null : random.nextInt(10) - 3;
} }
try { try {
execute(sql, params); execute(sql, params);
......
...@@ -79,11 +79,11 @@ public class Value { ...@@ -79,11 +79,11 @@ public class Value {
} }
private static Double randomDouble(TestSynth config) { private static Double randomDouble(TestSynth config) {
return new Double(config.random().getInt(100) / 10.); return config.random().getInt(100) / 10.;
} }
private static Long randomLong(TestSynth config) { private static Long randomLong(TestSynth config) {
return new Long(config.random().getInt(1000)); return Long.valueOf(config.random().getInt(1000));
} }
private static Time randomTime(TestSynth config) { private static Time randomTime(TestSynth config) {
...@@ -147,10 +147,10 @@ public class Value { ...@@ -147,10 +147,10 @@ public class Value {
switch (type) { switch (type) {
case Types.REAL: case Types.REAL:
case Types.DOUBLE: case Types.DOUBLE:
data = new Double(rs.getDouble(index)); data = rs.getDouble(index);
break; break;
case Types.BIGINT: case Types.BIGINT:
data = new Long(rs.getLong(index)); data = rs.getLong(index);
break; break;
case Types.DECIMAL: case Types.DECIMAL:
case Types.NUMERIC: case Types.NUMERIC:
...@@ -179,7 +179,7 @@ public class Value { ...@@ -179,7 +179,7 @@ public class Value {
data = rs.getTimestamp(index); data = rs.getTimestamp(index);
break; break;
case Types.INTEGER: case Types.INTEGER:
data = new Integer(rs.getInt(index)); data = rs.getInt(index);
break; break;
case Types.NULL: case Types.NULL:
data = null; data = null;
...@@ -260,7 +260,7 @@ public class Value { ...@@ -260,7 +260,7 @@ public class Value {
} else { } else {
value = config.random().getRandomInt(); value = config.random().getRandomInt();
} }
return new Integer(value); return value;
} }
private static byte[] randomBytes(TestSynth config, int max) { private static byte[] randomBytes(TestSynth config, int max) {
......
--- special grammar and test cases --------------------------------------------------------------------------------------------- --- special grammar and test cases ---------------------------------------------------------------------------------------------
create table test(d date, t time, ts timestamp);
> ok
insert into test values(date '2001-01-01', time '01:00:00', timestamp '2010-01-01 00:00:00');
> update count: 1
select ts + t x from test;
> X
> ---------------------
> 2010-01-01 01:00:00.0
> rows: 1
select ts + t + t - t x from test;
> X
> ---------------------
> 2010-01-01 01:00:00.0
> rows: 1
select ts + 0.5 * t + t - t x from test;
> X
> ---------------------
> 2010-01-01 00:30:00.0
> rows: 1
select ts + t / 0.5 x from test;
> X
> ---------------------
> 2010-01-01 02:00:00.0
> rows: 1
select d + t, t + d - t x from test;
> T + D X
> --------------------- ---------------------
> 2001-01-01 01:00:00.0 2001-01-01 00:00:00.0
> rows: 1
select 1 + d + 1, d - 1, 2 + ts + 2, ts - 2 from test;
> DATEADD('DAY', 1, DATEADD('DAY', 1, D)) DATEADD('DAY', -1, D) DATEADD('DAY', 2, DATEADD('DAY', 2, TS)) DATEADD('DAY', -2, TS)
> --------------------------------------- --------------------- ---------------------------------------- ----------------------
> 2001-01-03 00:00:00.0 2000-12-31 00:00:00.0 2010-01-05 00:00:00.0 2009-12-30 00:00:00.0
> rows: 1
select 1 + d + t + 1 from test;
> DATEADD('DAY', 1, (T + DATEADD('DAY', 1, D)))
> ---------------------------------------------
> 2001-01-03 01:00:00.0
> rows: 1
select ts - t - 2 from test;
> DATEADD('DAY', -2, (TS - T))
> ----------------------------
> 2009-12-29 23:00:00.0
> rows: 1
drop table test;
> ok
create table test(id int primary key); create table test(id int primary key);
> ok > ok
......
...@@ -183,16 +183,16 @@ class Parser { ...@@ -183,16 +183,16 @@ class Parser {
} else if (tokenType == NUMBER) { } else if (tokenType == NUMBER) {
String number = readToken().toLowerCase(); String number = readToken().toLowerCase();
if (number.endsWith("f")) { if (number.endsWith("f")) {
Float v = new Float(Float.parseFloat(number)); Float v = Float.parseFloat(number);
return new Arg(float.class, v); return new Arg(float.class, v);
} else if (number.endsWith("d") || number.indexOf("e") >= 0 || number.indexOf(".") >= 0) { } else if (number.endsWith("d") || number.indexOf("e") >= 0 || number.indexOf(".") >= 0) {
Double v = new Double(Double.parseDouble(number)); Double v = Double.parseDouble(number);
return new Arg(double.class, v); return new Arg(double.class, v);
} else if (number.endsWith("L") || number.endsWith("l")) { } else if (number.endsWith("L") || number.endsWith("l")) {
Long v = new Long(Long.parseLong(number.substring(0, number.length() - 1))); Long v = Long.parseLong(number.substring(0, number.length() - 1));
return new Arg(long.class, v); return new Arg(long.class, v);
} else { } else {
Integer v = new Integer(Integer.parseInt(number)); Integer v = Integer.parseInt(number);
return new Arg(int.class, v); return new Arg(int.class, v);
} }
} else if (tokenType == NAME) { } else if (tokenType == NAME) {
...@@ -241,7 +241,7 @@ class Parser { ...@@ -241,7 +241,7 @@ class Parser {
read("short"); read("short");
read(")"); read(")");
String number = readToken(); String number = readToken();
return new Arg(short.class, new Short(Short.parseShort(number))); return new Arg(short.class, Short.parseShort(number));
} else { } else {
throw new RuntimeException("Value expected, got: " + readToken() + " in " throw new RuntimeException("Value expected, got: " + readToken() + " in "
+ line); + line);
......
...@@ -110,6 +110,7 @@ public class Player { ...@@ -110,6 +110,7 @@ public class Player {
} }
runLine(line.trim()); runLine(line.trim());
} }
reader.close();
} }
/** /**
......
...@@ -115,7 +115,7 @@ public class TestCache extends TestBase implements CacheWriter { ...@@ -115,7 +115,7 @@ public class TestCache extends TestBase implements CacheWriter {
/** /**
* A simple cache object * A simple cache object
*/ */
class Obj extends CacheObject { static class Obj extends CacheObject {
Obj(int pos) { Obj(int pos) {
setPos(pos); setPos(pos);
......
...@@ -101,7 +101,6 @@ public class TestJmx extends TestBase { ...@@ -101,7 +101,6 @@ public class TestJmx extends TestBase {
conn.close(); conn.close();
conn = getConnection("jmx;jmx=true"); conn = getConnection("jmx;jmx=true");
stat = conn.createStatement();
name = new ObjectName("org.h2:name=JMX,*"); name = new ObjectName("org.h2:name=JMX,*");
Set<ObjectName> set = mbeanServer.queryNames(name, null); Set<ObjectName> set = mbeanServer.queryNames(name, null);
......
...@@ -89,7 +89,7 @@ public class TestNetUtils extends TestBase { ...@@ -89,7 +89,7 @@ public class TestNetUtils extends TestBase {
/** /**
* A worker thread to test connecting. * A worker thread to test connecting.
*/ */
private class ConnectWorker extends Thread { private static class ConnectWorker extends Thread {
private final boolean ssl; private final boolean ssl;
private final AtomicInteger counter; private final AtomicInteger counter;
......
...@@ -49,7 +49,7 @@ public class TestOldVersion extends TestBase { ...@@ -49,7 +49,7 @@ public class TestOldVersion extends TestBase {
Server server = org.h2.tools.Server.createTcpServer("-tcpPort", "9001"); Server server = org.h2.tools.Server.createTcpServer("-tcpPort", "9001");
server.start(); server.start();
try { try {
conn = driver.connect("jdbc:h2:tcp://localhost:9001/mem:test", null); driver.connect("jdbc:h2:tcp://localhost:9001/mem:test", null);
} catch (SQLException e) { } catch (SQLException e) {
assertEquals(ErrorCode.DRIVER_VERSION_ERROR_2, e.getErrorCode()); assertEquals(ErrorCode.DRIVER_VERSION_ERROR_2, e.getErrorCode());
} }
......
...@@ -715,7 +715,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener { ...@@ -715,7 +715,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
Random random = new Random(seed); Random random = new Random(seed);
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
int op = random.nextInt(3); int op = random.nextInt(3);
Integer x = new Integer(random.nextInt(100)); Integer x = random.nextInt(100);
switch (op) { switch (op) {
case 0: case 0:
if (!rows.contains(x)) { if (!rows.contains(x)) {
......
...@@ -247,6 +247,7 @@ public class TestPageStoreCoverage extends TestBase { ...@@ -247,6 +247,7 @@ public class TestPageStoreCoverage extends TestBase {
f.setFileLength(16); f.setFileLength(16);
// create a new database // create a new database
conn = getConnection("pageStore"); conn = getConnection("pageStore");
conn.close();
deleteDb("pageStore"); deleteDb("pageStore");
} }
......
...@@ -153,7 +153,8 @@ public class TestReopen extends TestBase implements Recorder { ...@@ -153,7 +153,8 @@ public class TestReopen extends TestBase implements Recorder {
database.removeSession(null); database.removeSession(null);
} catch (Exception e) { } catch (Exception e) {
int errorCode = 0; int errorCode = 0;
if (e instanceof SQLException) { if (e instanceof DbException) {
e = ((DbException) e).getSQLException();
errorCode = ((SQLException) e).getErrorCode(); errorCode = ((SQLException) e).getErrorCode();
} }
if (errorCode == ErrorCode.WRONG_USER_OR_PASSWORD) { if (errorCode == ErrorCode.WRONG_USER_OR_PASSWORD) {
......
...@@ -668,7 +668,7 @@ public class TestTools extends TestBase { ...@@ -668,7 +668,7 @@ public class TestTools extends TestBase {
"-baseDir", getBaseDir(), "-baseDir", getBaseDir(),
"-tcpPort", "9192").start(); "-tcpPort", "9192").start();
try { try {
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test2", "sa", ""); DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test2", "sa", "");
fail("should not be able to create new db"); fail("should not be able to create new db");
} catch (SQLException e) { } catch (SQLException e) {
assertKnownException(e); assertKnownException(e);
...@@ -707,7 +707,7 @@ public class TestTools extends TestBase { ...@@ -707,7 +707,7 @@ public class TestTools extends TestBase {
conn.close(); conn.close();
try { try {
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/../test", "sa", ""); DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/../test", "sa", "");
fail("Should throw an exception!"); fail("Should throw an exception!");
} catch (Throwable e) { } catch (Throwable e) {
// Expected // Expected
......
...@@ -220,10 +220,10 @@ public class BuildBase { ...@@ -220,10 +220,10 @@ public class BuildBase {
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
if (line.length() == 0) { if (line == null || line.equals("exit") || line.equals("quit")) {
line = last;
} else if (line.equals("exit") || line.equals("quit")) {
break; break;
} else if (line.length() == 0) {
line = last;
} }
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
try { try {
......
...@@ -17,7 +17,7 @@ public class Function implements Token { ...@@ -17,7 +17,7 @@ public class Function implements Token {
//## Java 1.5 begin ## //## Java 1.5 begin ##
// must be a new instance // must be a new instance
private static final Long COUNT_STAR = new Long(0); private static final Long COUNT_STAR = Long.valueOf(0);
protected Object[] x; protected Object[] x;
private String name; private String name;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论