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

Use varargs.

上级 7ad501b1
...@@ -482,7 +482,7 @@ java -cp h2*.jar org.h2.tools.Server -baseDir ~ ...@@ -482,7 +482,7 @@ java -cp h2*.jar org.h2.tools.Server -baseDir ~
The PG server can be started and stopped from within a Java application as follows: The PG server can be started and stopped from within a Java application as follows:
</p> </p>
<pre> <pre>
Server server = Server.createPgServer(new String[]{"-baseDir", "~"}); Server server = Server.createPgServer("-baseDir", "~");
server.start(); server.start();
... ...
server.stop(); server.stop();
......
...@@ -18,7 +18,8 @@ Change Log ...@@ -18,7 +18,8 @@ Change Log
<h1>Change Log</h1> <h1>Change Log</h1>
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul><li>H2 Console: indexes of tables of non-default schemas are now also listed. <ul><li>Various tools now use Java 5 var-args, such as main the methods and SimpleResultSet.addRow.
</li><li>H2 Console: indexes of tables of non-default schemas are now also listed.
</li><li>Issue 111: Multi-version concurrency / duplicate primary key after rollback. </li><li>Issue 111: Multi-version concurrency / duplicate primary key after rollback.
</li><li>Issue 110: Multi-version concurrency / wrong exception is thrown. </li><li>Issue 110: Multi-version concurrency / wrong exception is thrown.
</li><li>Parser: sequenceName.NEXTVAL and CURRVAL did not respect the schema search path. </li><li>Parser: sequenceName.NEXTVAL and CURRVAL did not respect the schema search path.
......
...@@ -1544,8 +1544,8 @@ public static ResultSet simpleResultSet() throws SQLException { ...@@ -1544,8 +1544,8 @@ public static ResultSet simpleResultSet() throws SQLException {
SimpleResultSet rs = new SimpleResultSet(); SimpleResultSet rs = new SimpleResultSet();
rs.addColumn("ID", Types.INTEGER, 10, 0); rs.addColumn("ID", Types.INTEGER, 10, 0);
rs.addColumn("NAME", Types.VARCHAR, 255, 0); rs.addColumn("NAME", Types.VARCHAR, 255, 0);
rs.addRow(new Object[] { new Integer(0), "Hello" }); rs.addRow(0, "Hello");
rs.addRow(new Object[] { new Integer(1), "World" }); rs.addRow(1, "World");
return rs; return rs;
} }
...@@ -1576,8 +1576,7 @@ public static ResultSet getMatrix(Connection conn, Integer size) ...@@ -1576,8 +1576,7 @@ public static ResultSet getMatrix(Connection conn, Integer size)
} }
for (int s = size.intValue(), x = 0; x &lt; s; x++) { for (int s = size.intValue(), x = 0; x &lt; s; x++) {
for (int y = 0; y &lt; s; y++) { for (int y = 0; y &lt; s; y++) {
rs.addRow(new Object[] { rs.addRow(x, y);
new Integer(x), new Integer(y) });
} }
} }
return rs; return rs;
......
...@@ -22,6 +22,10 @@ Of course, patches are always welcome, but are not always applied as is. ...@@ -22,6 +22,10 @@ Of course, patches are always welcome, but are not always applied as is.
See also <a href="build.html#providing_patches">Providing Patches</a>. See also <a href="build.html#providing_patches">Providing Patches</a>.
</p> </p>
<h2>Version 1.2</h2>
<ul><li>Enable system property h2.optimizeInList by default
</li></ul>
<h2>Priority 1</h2> <h2>Priority 1</h2>
<ul> <ul>
<li>Bugfixes <li>Bugfixes
...@@ -44,7 +48,7 @@ See also <a href="build.html#providing_patches">Providing Patches</a>. ...@@ -44,7 +48,7 @@ See also <a href="build.html#providing_patches">Providing Patches</a>.
</li><li>Test multi-threaded in-memory db access </li><li>Test multi-threaded in-memory db access
</li><li>MVCC: select for update should only lock the selected rows. </li><li>MVCC: select for update should only lock the selected rows.
</li><li>Option to shutdown all the running servers (on the same VM). </li><li>Option to shutdown all the running servers (on the same VM).
</li><li>Index organized tables CREATE TABLE...(...) ORGANIZATION INDEX (store in data file) (probably file format changes are required for rowId) </li><li>[Requires page store] Index organized tables CREATE TABLE...(...) ORGANIZATION INDEX
</li><li>[Requires page store] Better space re-use in the files after deleting data: shrink the data file without closing the database (if the end of the file is empty) </li><li>[Requires page store] Better space re-use in the files after deleting data: shrink the data file without closing the database (if the end of the file is empty)
</li><li>Full outer joins </li><li>Full outer joins
</li><li>Implement INSTEAD OF trigger (for views, tables, metadata tables). </li><li>Implement INSTEAD OF trigger (for views, tables, metadata tables).
...@@ -55,7 +59,7 @@ See also <a href="build.html#providing_patches">Providing Patches</a>. ...@@ -55,7 +59,7 @@ See also <a href="build.html#providing_patches">Providing Patches</a>.
</li><li>Support hints for the optimizer (which index to use, enforce the join order). </li><li>Support hints for the optimizer (which index to use, enforce the join order).
</li><li>Change LOB mechanism (less files, keep index of lob files, point to files and row, delete unused files earlier, maybe bundle files into a tar file) </li><li>Change LOB mechanism (less files, keep index of lob files, point to files and row, delete unused files earlier, maybe bundle files into a tar file)
</li><li>Clustering: recovery needs to becomes fully automatic. Global write lock feature. </li><li>Clustering: recovery needs to becomes fully automatic. Global write lock feature.
</li><li>Support mixed clustering mode (one embedded, the other server mode) </li><li>Support mixed clustering mode (one embedded, others in server mode)
</li><li>Sequence: add features [NO] MINVALUE, MAXVALUE, CYCLE </li><li>Sequence: add features [NO] MINVALUE, MAXVALUE, CYCLE
</li><li>Deferred integrity checking (DEFERRABLE INITIALLY DEFERRED) </li><li>Deferred integrity checking (DEFERRABLE INITIALLY DEFERRED)
</li><li>Groovy Stored Procedures (http://groovy.codehaus.org/Groovy+SQL) </li><li>Groovy Stored Procedures (http://groovy.codehaus.org/Groovy+SQL)
......
...@@ -527,8 +527,8 @@ public class TestCsv { ...@@ -527,8 +527,8 @@ public class TestCsv {
SimpleResultSet rs = new SimpleResultSet(); SimpleResultSet rs = new SimpleResultSet();
rs.addColumn("NAME", Types.VARCHAR, 255, 0); rs.addColumn("NAME", Types.VARCHAR, 255, 0);
rs.addColumn("EMAIL", Types.VARCHAR, 255, 0); rs.addColumn("EMAIL", Types.VARCHAR, 255, 0);
rs.addRow(new String[] { "Bob Meier", "bob.meier@abcde.abc" }); rs.addRow("Bob Meier", "bob.meier@abcde.abc");
rs.addRow(new String[] { "John Jones", "john.jones@abcde.abc" }); rs.addRow("John Jones", "john.jones@abcde.abc");
Csv.getInstance().write("data/test.csv", rs, null); Csv.getInstance().write("data/test.csv", rs, null);
} }
} }
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -213,7 +213,7 @@ public abstract class Command implements CommandInterface { ...@@ -213,7 +213,7 @@ public abstract class Command implements CommandInterface {
if (e.getErrorCode() == ErrorCode.CONCURRENT_UPDATE_1) { if (e.getErrorCode() == ErrorCode.CONCURRENT_UPDATE_1) {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
if (now - start > session.getLockTimeout()) { if (now - start > session.getLockTimeout()) {
throw Message.getSQLException(ErrorCode.LOCK_TIMEOUT_1, new String[]{""}, e); throw Message.getSQLException(ErrorCode.LOCK_TIMEOUT_1, e, "");
} }
try { try {
if (sync == database) { if (sync == database) {
......
...@@ -2779,7 +2779,7 @@ public class Parser { ...@@ -2779,7 +2779,7 @@ public class Parser {
try { try {
bd = new BigDecimal(sub); bd = new BigDecimal(sub);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throw Message.getSQLException(ErrorCode.DATA_CONVERSION_ERROR_1, new String[] { sub }, e); throw Message.getSQLException(ErrorCode.DATA_CONVERSION_ERROR_1, e, sub);
} }
checkLiterals(false); checkLiterals(false);
currentValue = ValueDecimal.get(bd); currentValue = ValueDecimal.get(bd);
......
...@@ -202,8 +202,8 @@ public class AlterTableAlterColumn extends SchemaCommand { ...@@ -202,8 +202,8 @@ public class AlterTableAlterColumn extends SchemaCommand {
private void checkNoViews() throws SQLException { private void checkNoViews() throws SQLException {
for (DbObject child : table.getChildren()) { for (DbObject child : table.getChildren()) {
if (child.getType() == DbObject.TABLE_OR_VIEW) { if (child.getType() == DbObject.TABLE_OR_VIEW) {
throw Message.getSQLException(ErrorCode.OPERATION_NOT_SUPPORTED_WITH_VIEWS_2, new String[] { throw Message.getSQLException(ErrorCode.OPERATION_NOT_SUPPORTED_WITH_VIEWS_2,
table.getName(), child.getName() }); table.getName(), child.getName());
} }
} }
} }
......
...@@ -71,7 +71,7 @@ public class AlterSequence extends SchemaCommand { ...@@ -71,7 +71,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 Message.getSQLException(ErrorCode.INVALID_VALUE_2, new String[] { "0", "INCREMENT" }); throw Message.getSQLException(ErrorCode.INVALID_VALUE_2, "0", "INCREMENT");
} }
sequence.setIncrement(incrementValue); sequence.setIncrement(incrementValue);
} }
......
...@@ -72,7 +72,7 @@ public class CompressDeflate implements Compressor { ...@@ -72,7 +72,7 @@ public class CompressDeflate implements Compressor {
try { try {
decompresser.inflate(out, outPos, outLen); decompresser.inflate(out, outPos, outLen);
} catch (DataFormatException e) { } catch (DataFormatException e) {
throw Message.getSQLException(ErrorCode.COMPRESSION_ERROR, null, e); throw Message.getSQLException(ErrorCode.COMPRESSION_ERROR, e);
} }
decompresser.end(); decompresser.end();
} }
......
...@@ -1596,8 +1596,7 @@ public class ErrorCode { ...@@ -1596,8 +1596,7 @@ public class ErrorCode {
* </pre> * </pre>
* Or, when starting the server from an application, use: * Or, when starting the server from an application, use:
* <pre> * <pre>
* Server server = Server.createTcpServer(new String[] { * Server server = Server.createTcpServer("-tcpAllowOthers");
* "-tcpAllowOthers" });
* server.start(); * server.start();
* </pre> * </pre>
*/ */
......
...@@ -525,7 +525,7 @@ public class ConnectionInfo implements Cloneable { ...@@ -525,7 +525,7 @@ public class ConnectionInfo implements Cloneable {
*/ */
SQLException getFormatException() { SQLException getFormatException() {
String format = Constants.URL_FORMAT; String format = Constants.URL_FORMAT;
return Message.getSQLException(ErrorCode.URL_FORMAT_ERROR_2, new String[] { format, url }); return Message.getSQLException(ErrorCode.URL_FORMAT_ERROR_2, format, url);
} }
/** /**
......
...@@ -681,10 +681,10 @@ public class Database implements DataHandler { ...@@ -681,10 +681,10 @@ public class Database implements DataHandler {
} }
private void startServer(String key) throws SQLException { private void startServer(String key) throws SQLException {
server = Server.createTcpServer(new String[]{ server = Server.createTcpServer(
"-tcpPort", "0", "-tcpPort", "0",
"-tcpAllowOthers", "true", "-tcpAllowOthers", "true",
"-key", key, databaseName}); "-key", key, databaseName);
server.start(); server.start();
String address = NetUtils.getLocalAddress() + ":" + server.getPort(); String address = NetUtils.getLocalAddress() + ":" + server.getPort();
lock.setProperty("server", address); lock.setProperty("server", address);
...@@ -1711,7 +1711,7 @@ public class Database implements DataHandler { ...@@ -1711,7 +1711,7 @@ public class Database implements DataHandler {
} }
if (invalid != null) { if (invalid != null) {
obj.getSchema().add(obj); obj.getSchema().add(obj);
throw Message.getSQLException(ErrorCode.CANNOT_DROP_2, new String[] { obj.getSQL(), invalid }); throw Message.getSQLException(ErrorCode.CANNOT_DROP_2, obj.getSQL(), invalid);
} }
obj.removeChildrenAndResources(session); obj.removeChildrenAndResources(session);
} }
...@@ -1848,8 +1848,7 @@ public class Database implements DataHandler { ...@@ -1848,8 +1848,7 @@ public class Database implements DataHandler {
} }
eventListener.init(url); eventListener.init(url);
} catch (Throwable e) { } catch (Throwable e) {
throw Message.getSQLException(ErrorCode.ERROR_SETTING_DATABASE_EVENT_LISTENER_2, new String[] { throw Message.getSQLException(ErrorCode.ERROR_SETTING_DATABASE_EVENT_LISTENER_2, e, className, e.toString());
className, e.toString() }, e);
} }
} }
} }
......
...@@ -75,11 +75,9 @@ public class FunctionAlias extends DbObjectBase { ...@@ -75,11 +75,9 @@ public class FunctionAlias extends DbObjectBase {
JavaMethod javaMethod = new JavaMethod(m, i); JavaMethod javaMethod = new JavaMethod(m, i);
for (JavaMethod old : list) { for (JavaMethod old : list) {
if (old.getParameterCount() == javaMethod.getParameterCount()) { if (old.getParameterCount() == javaMethod.getParameterCount()) {
throw Message.getSQLException(ErrorCode.METHODS_MUST_HAVE_DIFFERENT_PARAMETER_COUNTS_2, throw Message.getSQLException(
new String[] { ErrorCode.METHODS_MUST_HAVE_DIFFERENT_PARAMETER_COUNTS_2,
old.toString(), old.toString(), javaMethod.toString()
javaMethod.toString()
}
); );
} }
} }
......
...@@ -226,7 +226,7 @@ public class User extends RightOwner { ...@@ -226,7 +226,7 @@ public class User extends RightOwner {
public void checkOwnsNoSchemas() throws SQLException { public void checkOwnsNoSchemas() throws SQLException {
for (Schema s : database.getAllSchemas()) { for (Schema s : database.getAllSchemas()) {
if (this == s.getOwner()) { if (this == s.getOwner()) {
throw Message.getSQLException(ErrorCode.CANNOT_DROP_2, new String[]{ getName(), s.getName() }); throw Message.getSQLException(ErrorCode.CANNOT_DROP_2, getName(), s.getName());
} }
} }
} }
......
...@@ -402,8 +402,8 @@ public class Function extends Expression implements FunctionCall { ...@@ -402,8 +402,8 @@ public class Function extends Expression implements FunctionCall {
varArgs.add(param); varArgs.add(param);
} else { } else {
if (index >= args.length) { if (index >= args.length) {
throw Message.getSQLException(ErrorCode.INVALID_PARAMETER_COUNT_2, new String[] { info.name, throw Message.getSQLException(ErrorCode.INVALID_PARAMETER_COUNT_2, info.name,
"" + args.length }); "" + args.length);
} }
args[index] = param; args[index] = param;
} }
...@@ -988,7 +988,7 @@ public class Function extends Expression implements FunctionCall { ...@@ -988,7 +988,7 @@ public class Function extends Expression implements FunctionCall {
try { try {
result = ValueString.get(v0.getString().replaceAll(regexp, v2.getString())); result = ValueString.get(v0.getString().replaceAll(regexp, v2.getString()));
} catch (PatternSyntaxException e) { } catch (PatternSyntaxException e) {
throw Message.getSQLException(ErrorCode.LIKE_ESCAPE_ERROR_1, new String[]{regexp}, e); throw Message.getSQLException(ErrorCode.LIKE_ESCAPE_ERROR_1, e, regexp);
} }
break; break;
} }
...@@ -1216,7 +1216,7 @@ public class Function extends Expression implements FunctionCall { ...@@ -1216,7 +1216,7 @@ public class Function extends Expression implements FunctionCall {
private static int getDatePart(String part) throws SQLException { private static int getDatePart(String part) throws SQLException {
Integer p = DATE_PART.get(StringUtils.toUpperEnglish(part)); Integer p = DATE_PART.get(StringUtils.toUpperEnglish(part));
if (p == null) { if (p == null) {
throw Message.getSQLException(ErrorCode.INVALID_VALUE_2, new String[] { "date part", part }); throw Message.getSQLException(ErrorCode.INVALID_VALUE_2, "date part", part);
} }
return p.intValue(); return p.intValue();
} }
...@@ -1553,8 +1553,7 @@ public class Function extends Expression implements FunctionCall { ...@@ -1553,8 +1553,7 @@ public class Function extends Expression implements FunctionCall {
} }
boolean ok = (len >= min) && (len <= max); boolean ok = (len >= min) && (len <= max);
if (!ok) { if (!ok) {
throw Message.getSQLException(ErrorCode.INVALID_PARAMETER_COUNT_2, new String[] { info.name, throw Message.getSQLException(ErrorCode.INVALID_PARAMETER_COUNT_2, info.name, min + ".." + max);
min + ".." + max });
} }
} }
...@@ -1575,7 +1574,7 @@ public class Function extends Expression implements FunctionCall { ...@@ -1575,7 +1574,7 @@ public class Function extends Expression implements FunctionCall {
int len = args.length; int len = args.length;
if (len > 0 && args[len - 1] == null) { if (len > 0 && args[len - 1] == null) {
throw Message throw Message
.getSQLException(ErrorCode.INVALID_PARAMETER_COUNT_2, new String[] { info.name, "" + len }); .getSQLException(ErrorCode.INVALID_PARAMETER_COUNT_2, info.name, "" + len);
} }
} }
} }
......
...@@ -44,8 +44,7 @@ public class TableFunction extends Function { ...@@ -44,8 +44,7 @@ public class TableFunction extends Function {
protected void checkParameterCount(int len) throws SQLException { protected void checkParameterCount(int len) throws SQLException {
if (len < 1) { if (len < 1) {
throw Message.getSQLException(ErrorCode.INVALID_PARAMETER_COUNT_2, new String[] { getName(), throw Message.getSQLException(ErrorCode.INVALID_PARAMETER_COUNT_2, getName(), ">0");
">0" });
} }
} }
......
...@@ -551,18 +551,16 @@ public class FullText { ...@@ -551,18 +551,16 @@ public class FullText {
IndexInfo index = setting.getIndexInfo(indexId); IndexInfo index = setting.getIndexInfo(indexId);
if (data) { if (data) {
Object[][] columnData = parseKey(conn, key); Object[][] columnData = parseKey(conn, key);
Object[] row = new Object[] { result.addRow(
index.schema, index.schema,
index.table, index.table,
columnData[0], columnData[0],
columnData[1] columnData[1]);
};
result.addRow(row);
} else { } else {
String query = StringUtils.quoteIdentifier(index.schema) + String query = StringUtils.quoteIdentifier(index.schema) +
"." + StringUtils.quoteIdentifier(index.table) + "." + StringUtils.quoteIdentifier(index.table) +
" WHERE " + key; " WHERE " + key;
result.addRow(new String[] { query }); result.addRow(query);
} }
rowCount++; rowCount++;
if (limit > 0 && rowCount >= limit) { if (limit > 0 && rowCount >= limit) {
......
...@@ -357,15 +357,13 @@ public class FullTextLucene extends FullText { ...@@ -357,15 +357,13 @@ public class FullTextLucene extends FullText {
String tableName = expr.getColumnName(); String tableName = expr.getColumnName();
q = q.substring(idx + " WHERE ".length()); q = q.substring(idx + " WHERE ".length());
Object[][] columnData = parseKey(conn, q); Object[][] columnData = parseKey(conn, q);
Object[] row = new Object[] { result.addRow(
schemaName, schemaName,
tableName, tableName,
columnData[0], columnData[0],
columnData[1] columnData[1]);
};
result.addRow(row);
} else { } else {
result.addRow(new Object[] { q }); result.addRow(q);
} }
} }
// TODO keep it open if possible // TODO keep it open if possible
......
...@@ -59,6 +59,7 @@ public class IndexCursor implements Cursor { ...@@ -59,6 +59,7 @@ public class IndexCursor implements Cursor {
/** /**
* Re-evaluate the start and end values of the index search for rows. * Re-evaluate the start and end values of the index search for rows.
* *
* @param session the session
* @param indexConditions the index conditions * @param indexConditions the index conditions
*/ */
public void find(Session session, ObjectArray<IndexCondition> indexConditions) throws SQLException { public void find(Session session, ObjectArray<IndexCondition> indexConditions) throws SQLException {
......
...@@ -242,10 +242,7 @@ public class JdbcArray extends TraceObject implements Array { ...@@ -242,10 +242,7 @@ public class JdbcArray extends TraceObject implements Array {
// TODO array result set: there are multiple data types possible // TODO array result set: there are multiple data types possible
rs.addColumn("VALUE", Types.NULL, 0, 0); rs.addColumn("VALUE", Types.NULL, 0, 0);
for (int i = 0; i < array.length; i++) { for (int i = 0; i < array.length; i++) {
Object[] row = new Object[2]; rs.addRow(Long.valueOf(offset + i + 1), array[i]);
row[0] = Long.valueOf(offset + i + 1);
row[1] = array[i];
rs.addRow(row);
} }
return rs; return rs;
} }
......
...@@ -45,7 +45,7 @@ import org.h2.message.Message; ...@@ -45,7 +45,7 @@ import org.h2.message.Message;
* import java.sql.*; * import java.sql.*;
* import org.h2.jdbcx.JdbcConnectionPool; * import org.h2.jdbcx.JdbcConnectionPool;
* public class Test { * public class Test {
* public static void main(String[] args) throws Exception { * public static void main(String... args) throws Exception {
* JdbcConnectionPool cp = JdbcConnectionPool.create( * JdbcConnectionPool cp = JdbcConnectionPool.create(
* "jdbc:h2:~/test", "sa", "sa"); * "jdbc:h2:~/test", "sa", "sa");
* for (String sql : args) { * for (String sql : args) {
......
...@@ -75,7 +75,7 @@ public class Message { ...@@ -75,7 +75,7 @@ public class Message {
return getSQLException(errorCode, new String[] { p1 }); return getSQLException(errorCode, new String[] { p1 });
} }
private static String translate(String key, String[] param) { private static String translate(String key, String... param) {
String message = null; String message = null;
if (MESSAGES != null) { if (MESSAGES != null) {
// Tomcat sets final static fields to null sometimes // Tomcat sets final static fields to null sometimes
...@@ -95,11 +95,11 @@ public class Message { ...@@ -95,11 +95,11 @@ public class Message {
* Gets the SQL exception object for a specific error code. * Gets the SQL exception object for a specific error code.
* *
* @param errorCode the error code * @param errorCode the error code
* @param params the list of parameters of the message
* @param cause the cause of the exception * @param cause the cause of the exception
* @param params the list of parameters of the message
* @return the SQLException object * @return the SQLException object
*/ */
public static JdbcSQLException getSQLException(int errorCode, String[] params, Throwable cause) { public static JdbcSQLException getSQLException(int errorCode, Throwable cause, String... params) {
String sqlstate = ErrorCode.getState(errorCode); String sqlstate = ErrorCode.getState(errorCode);
String message = translate(sqlstate, params); String message = translate(sqlstate, params);
return new JdbcSQLException(message, null, sqlstate, errorCode, cause, null); return new JdbcSQLException(message, null, sqlstate, errorCode, cause, null);
...@@ -112,8 +112,8 @@ public class Message { ...@@ -112,8 +112,8 @@ public class Message {
* @param params the list of parameters of the message * @param params the list of parameters of the message
* @return the SQLException object * @return the SQLException object
*/ */
public static JdbcSQLException getSQLException(int errorCode, String[] params) { public static JdbcSQLException getSQLException(int errorCode, String... params) {
return getSQLException(errorCode, params, null); return getSQLException(errorCode, null, params);
} }
/** /**
...@@ -138,7 +138,7 @@ public class Message { ...@@ -138,7 +138,7 @@ public class Message {
*/ */
public static SQLException getSyntaxError(String sql, int index, String expected) { public static SQLException getSyntaxError(String sql, int index, String expected) {
sql = StringUtils.addAsterisk(sql, index); sql = StringUtils.addAsterisk(sql, index);
return getSQLException(ErrorCode.SYNTAX_ERROR_2, new String[] { sql, expected }); return getSQLException(ErrorCode.SYNTAX_ERROR_2, sql, expected);
} }
/** /**
...@@ -169,7 +169,7 @@ public class Message { ...@@ -169,7 +169,7 @@ public class Message {
* @return the SQLException object * @return the SQLException object
*/ */
public static JdbcSQLException getInvalidValueException(String value, String param) { public static JdbcSQLException getInvalidValueException(String value, String param) {
return getSQLException(ErrorCode.INVALID_VALUE_2, new String[] { value, param }); return getSQLException(ErrorCode.INVALID_VALUE_2, value, param);
} }
/** /**
...@@ -260,18 +260,18 @@ public class Message { ...@@ -260,18 +260,18 @@ public class Message {
if (e instanceof SQLException) { if (e instanceof SQLException) {
return (SQLException) e; return (SQLException) e;
} else if (e instanceof OutOfMemoryError) { } else if (e instanceof OutOfMemoryError) {
return getSQLException(ErrorCode.OUT_OF_MEMORY, null, e); return getSQLException(ErrorCode.OUT_OF_MEMORY, e);
} else if (e instanceof InvocationTargetException) { } else if (e instanceof InvocationTargetException) {
InvocationTargetException te = (InvocationTargetException) e; InvocationTargetException te = (InvocationTargetException) e;
Throwable t = te.getTargetException(); Throwable t = te.getTargetException();
if (t instanceof SQLException) { if (t instanceof SQLException) {
return (SQLException) t; return (SQLException) t;
} }
return getSQLException(ErrorCode.EXCEPTION_IN_FUNCTION, null, e); return getSQLException(ErrorCode.EXCEPTION_IN_FUNCTION, e);
} else if (e instanceof IOException) { } else if (e instanceof IOException) {
return getSQLException(ErrorCode.IO_EXCEPTION_1, new String[] { e.toString() }, e); return getSQLException(ErrorCode.IO_EXCEPTION_1, e, e.toString());
} }
return getSQLException(ErrorCode.GENERAL_ERROR_1, new String[] { e.toString() }, e); return getSQLException(ErrorCode.GENERAL_ERROR_1, e, e.toString());
} }
/** /**
...@@ -287,9 +287,9 @@ public class Message { ...@@ -287,9 +287,9 @@ public class Message {
if (t != null && t instanceof SQLException) { if (t != null && t instanceof SQLException) {
return (SQLException) t; return (SQLException) t;
} }
return getSQLException(ErrorCode.IO_EXCEPTION_1, new String[] { e.toString() }, e); return getSQLException(ErrorCode.IO_EXCEPTION_1, e, e.toString());
} }
return getSQLException(ErrorCode.IO_EXCEPTION_2, new String[] { e.toString(), message }, e); return getSQLException(ErrorCode.IO_EXCEPTION_2, e, e.toString(), message);
} }
/** /**
......
...@@ -194,7 +194,7 @@ public class TraceSystem implements TraceWriter { ...@@ -194,7 +194,7 @@ public class TraceSystem implements TraceWriter {
try { try {
writer = (TraceWriter) ClassUtils.loadSystemClass(adapterClass).newInstance(); writer = (TraceWriter) ClassUtils.loadSystemClass(adapterClass).newInstance();
} catch (Throwable e) { } catch (Throwable e) {
e = Message.getSQLException(ErrorCode.CLASS_NOT_FOUND_1, new String[] { adapterClass }, e); e = Message.getSQLException(ErrorCode.CLASS_NOT_FOUND_1, e, adapterClass);
write(ERROR, Trace.DATABASE, adapterClass, e); write(ERROR, Trace.DATABASE, adapterClass, e);
return; return;
} }
...@@ -284,8 +284,7 @@ public class TraceSystem implements TraceWriter { ...@@ -284,8 +284,7 @@ public class TraceSystem implements TraceWriter {
return; return;
} }
writingErrorLogged = true; writingErrorLogged = true;
SQLException se = Message.getSQLException(ErrorCode.TRACE_FILE_ERROR_2, new String[] { fileName, e.toString() }, SQLException se = Message.getSQLException(ErrorCode.TRACE_FILE_ERROR_2, e, fileName, e.toString());
e);
// print this error only once // print this error only once
fileName = null; fileName = null;
System.out.println(se); System.out.println(se);
......
...@@ -52,7 +52,7 @@ public class Sequence extends SchemaObjectBase { ...@@ -52,7 +52,7 @@ public class Sequence extends SchemaObjectBase {
public void setIncrement(long inc) throws SQLException { public void setIncrement(long inc) throws SQLException {
if (inc == 0) { if (inc == 0) {
throw Message.getSQLException(ErrorCode.INVALID_VALUE_2, new String[] { "0", "INCREMENT" }, null); throw Message.getSQLException(ErrorCode.INVALID_VALUE_2, "0", "INCREMENT");
} }
this.increment = inc; this.increment = inc;
} }
......
...@@ -66,8 +66,8 @@ public class TriggerObject extends SchemaObjectBase { ...@@ -66,8 +66,8 @@ public class TriggerObject extends SchemaObjectBase {
} catch (Throwable e) { } catch (Throwable e) {
// try again later // try again later
triggerCallback = null; triggerCallback = null;
throw Message.getSQLException(ErrorCode.ERROR_CREATING_TRIGGER_OBJECT_3, new String[] { getName(), throw Message.getSQLException(ErrorCode.ERROR_CREATING_TRIGGER_OBJECT_3, e, getName(),
triggerClassName, e.toString() }, e); triggerClassName, e.toString());
} }
} }
...@@ -108,8 +108,8 @@ public class TriggerObject extends SchemaObjectBase { ...@@ -108,8 +108,8 @@ public class TriggerObject extends SchemaObjectBase {
try { try {
triggerCallback.fire(c2, null, null); triggerCallback.fire(c2, null, null);
} catch (Throwable e) { } catch (Throwable e) {
throw Message.getSQLException(ErrorCode.ERROR_EXECUTING_TRIGGER_3, new String[] { getName(), throw Message.getSQLException(ErrorCode.ERROR_EXECUTING_TRIGGER_3, e, getName(),
triggerClassName, e.toString() }, e); triggerClassName, e.toString());
} finally { } finally {
session.setCommitOrRollbackDisabled(old); session.setCommitOrRollbackDisabled(old);
} }
......
...@@ -21,7 +21,7 @@ public interface Service { ...@@ -21,7 +21,7 @@ public interface Service {
* *
* @param args the command line options * @param args the command line options
*/ */
void init(String[] args) throws Exception; void init(String... args) throws Exception;
/** /**
* Get the URL of this service in a human readable form * Get the URL of this service in a human readable form
......
...@@ -146,7 +146,7 @@ public class TcpServer implements Service { ...@@ -146,7 +146,7 @@ public class TcpServer implements Service {
} }
} }
public void init(String[] args) { public void init(String... args) {
port = DEFAULT_PORT; port = DEFAULT_PORT;
for (int i = 0; args != null && i < args.length; i++) { for (int i = 0; args != null && i < args.length; i++) {
String a = args[i]; String a = args[i];
......
...@@ -74,8 +74,9 @@ public class TcpServerThread implements Runnable { ...@@ -74,8 +74,9 @@ public class TcpServerThread implements Runnable {
// version 6 and newer: read max version (currently not used) // version 6 and newer: read max version (currently not used)
transfer.readInt(); transfer.readInt();
} else if (clientVersion != Constants.TCP_PROTOCOL_VERSION_5) { } else if (clientVersion != Constants.TCP_PROTOCOL_VERSION_5) {
throw Message.getSQLException(ErrorCode.DRIVER_VERSION_ERROR_2, new String[] { "" + clientVersion, throw Message.getSQLException(ErrorCode.DRIVER_VERSION_ERROR_2,
"" + Constants.TCP_PROTOCOL_VERSION_5 }); "" + clientVersion,
"" + Constants.TCP_PROTOCOL_VERSION_5);
} }
String db = transfer.readString(); String db = transfer.readString();
String originalURL = transfer.readString(); String originalURL = transfer.readString();
......
...@@ -72,7 +72,7 @@ public class PgServer implements Service { ...@@ -72,7 +72,7 @@ public class PgServer implements Service {
private boolean allowOthers; private boolean allowOthers;
private boolean ifExists; private boolean ifExists;
public void init(String[] args) { public void init(String... args) {
port = DEFAULT_PORT; port = DEFAULT_PORT;
for (int i = 0; args != null && i < args.length; i++) { for (int i = 0; args != null && i < args.length; i++) {
String a = args[i]; String a = args[i];
......
...@@ -216,7 +216,7 @@ public class WebServer implements Service { ...@@ -216,7 +216,7 @@ public class WebServer implements Service {
return startDateTime; return startDateTime;
} }
public void init(String[] args) { public void init(String... args) {
// TODO web: support using a different properties file // TODO web: support using a different properties file
Properties prop = loadProperties(); Properties prop = loadProperties();
port = SortedProperties.getIntProperty(prop, "webPort", Constants.DEFAULT_HTTP_PORT); port = SortedProperties.getIntProperty(prop, "webPort", Constants.DEFAULT_HTTP_PORT);
......
...@@ -449,7 +449,7 @@ public class FileLock { ...@@ -449,7 +449,7 @@ public class FileLock {
} }
private SQLException getExceptionFatal(String reason, Throwable t) { private SQLException getExceptionFatal(String reason, Throwable t) {
return Message.getSQLException(ErrorCode.ERROR_OPENING_DATABASE_1, new String[]{reason}, t); return Message.getSQLException(ErrorCode.ERROR_OPENING_DATABASE_1, t, reason);
} }
private SQLException getExceptionAlreadyInUse(String reason) { private SQLException getExceptionAlreadyInUse(String reason) {
......
...@@ -50,11 +50,11 @@ public class FileObjectDiskMapped implements FileObject { ...@@ -50,11 +50,11 @@ public class FileObjectDiskMapped implements FileObject {
if (SysProperties.NIO_CLEANER_HACK) { if (SysProperties.NIO_CLEANER_HACK) {
try { try {
useSystemGc = false; useSystemGc = false;
Method cleanerMethod = mapped.getClass().getMethod("cleaner", new Class[0]); Method cleanerMethod = mapped.getClass().getMethod("cleaner");
cleanerMethod.setAccessible(true); cleanerMethod.setAccessible(true);
Object cleaner = cleanerMethod.invoke(mapped, new Object[0]); Object cleaner = cleanerMethod.invoke(mapped);
Method clearMethod = cleaner.getClass().getMethod("clear", new Class[0]); Method clearMethod = cleaner.getClass().getMethod("clear");
clearMethod.invoke(cleaner, new Object[0]); clearMethod.invoke(cleaner);
} catch (Throwable e) { } catch (Throwable e) {
useSystemGc = true; useSystemGc = true;
} }
......
...@@ -71,8 +71,9 @@ public class FileSystemDisk extends FileSystem { ...@@ -71,8 +71,9 @@ public class FileSystemDisk extends FileSystem {
Message.throwInternalError("rename file old=new"); Message.throwInternalError("rename file old=new");
} }
if (!oldFile.exists()) { if (!oldFile.exists()) {
throw Message.getSQLException(ErrorCode.FILE_RENAME_FAILED_2, new String[] { oldName + " (not found)", throw Message.getSQLException(ErrorCode.FILE_RENAME_FAILED_2,
newName }); oldName + " (not found)",
newName);
} }
if (newFile.exists()) { if (newFile.exists()) {
throw Message.getSQLException(ErrorCode.FILE_RENAME_FAILED_2, throw Message.getSQLException(ErrorCode.FILE_RENAME_FAILED_2,
......
...@@ -299,7 +299,7 @@ public class Column { ...@@ -299,7 +299,7 @@ public class Column {
s = s.substring(0, 128) + "..."; s = s.substring(0, 128) + "...";
} }
throw Message.getSQLException(ErrorCode.VALUE_TOO_LONG_2, throw Message.getSQLException(ErrorCode.VALUE_TOO_LONG_2,
new String[] { getCreateSQL(), s + " (" + value.getPrecision() + ")" }); getCreateSQL(), s + " (" + value.getPrecision() + ")");
} }
} }
updateSequenceIfRequired(session, value); updateSequenceIfRequired(session, value);
......
...@@ -74,7 +74,7 @@ public class LinkSchema { ...@@ -74,7 +74,7 @@ public class LinkSchema {
append(StringUtils.quoteStringSQL(table)). append(StringUtils.quoteStringSQL(table)).
append(')'); append(')');
stat.execute(buff.toString()); stat.execute(buff.toString());
result.addRow(new String[] { table }); result.addRow(table);
} }
} finally { } finally {
JdbcUtils.closeSilently(rs); JdbcUtils.closeSilently(rs);
......
...@@ -169,8 +169,8 @@ public class TableLink extends Table { ...@@ -169,8 +169,8 @@ public class TableLink extends Table {
} }
rs.close(); rs.close();
} catch (SQLException e) { } catch (SQLException e) {
throw Message.getSQLException(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, new String[] { originalTable + "(" throw Message.getSQLException(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, e,
+ e.toString() + ")" }, e); originalTable + "(" + e.toString() + ")");
} finally { } finally {
JdbcUtils.closeSilently(stat); JdbcUtils.closeSilently(stat);
} }
...@@ -391,7 +391,7 @@ public class TableLink extends Table { ...@@ -391,7 +391,7 @@ public class TableLink extends Table {
* @return the wrapped SQL exception * @return the wrapped SQL exception
*/ */
public SQLException wrapException(String sql, SQLException e) { public SQLException wrapException(String sql, SQLException e) {
return Message.getSQLException(ErrorCode.ERROR_ACCESSING_LINKED_TABLE_2, new String[] { sql, e.toString() }, e); return Message.getSQLException(ErrorCode.ERROR_ACCESSING_LINKED_TABLE_2, e, sql, e.toString());
} }
public String getQualifiedTable() { public String getQualifiedTable() {
......
...@@ -256,7 +256,7 @@ public class TableView extends Table { ...@@ -256,7 +256,7 @@ public class TableView extends Table {
public Index getScanIndex(Session session) throws SQLException { public Index getScanIndex(Session session) throws SQLException {
if (createException != null) { if (createException != null) {
String msg = createException.getMessage(); String msg = createException.getMessage();
throw Message.getSQLException(ErrorCode.VIEW_IS_INVALID_2, new String[] { getSQL(), msg }, createException); throw Message.getSQLException(ErrorCode.VIEW_IS_INVALID_2, createException, getSQL(), msg);
} }
PlanItem item = getBestPlanItem(session, null); PlanItem item = getBestPlanItem(session, null);
return item.getIndex(); return item.getIndex();
......
...@@ -46,11 +46,11 @@ public class Backup extends Tool { ...@@ -46,11 +46,11 @@ public class Backup extends Tool {
* *
* @param args the command line arguments * @param args the command line arguments
*/ */
public static void main(String[] args) throws SQLException { public static void main(String... args) throws SQLException {
new Backup().run(args); new Backup().run(args);
} }
public void run(String[] args) throws SQLException { public void run(String... args) throws SQLException {
String zipFileName = "backup.zip"; String zipFileName = "backup.zip";
String dir = "."; String dir = ".";
String db = null; String db = null;
......
...@@ -51,11 +51,11 @@ public class ChangeFileEncryption extends Tool { ...@@ -51,11 +51,11 @@ public class ChangeFileEncryption extends Tool {
* *
* @param args the command line arguments * @param args the command line arguments
*/ */
public static void main(String[] args) throws SQLException { public static void main(String... args) throws SQLException {
new ChangeFileEncryption().run(args); new ChangeFileEncryption().run(args);
} }
public void run(String[] args) throws SQLException { public void run(String... args) throws SQLException {
String dir = "."; String dir = ".";
String cipher = null; String cipher = null;
char[] decryptPassword = null; char[] decryptPassword = null;
......
...@@ -117,7 +117,7 @@ public class CompressTool { ...@@ -117,7 +117,7 @@ public class CompressTool {
compress.expand(in, start, in.length - start, buff, 0, len); compress.expand(in, start, in.length - start, buff, 0, len);
return buff; return buff;
} catch (Exception e) { } catch (Exception e) {
throw Message.getSQLException(ErrorCode.COMPRESSION_ERROR, null, e); throw Message.getSQLException(ErrorCode.COMPRESSION_ERROR, e);
} }
} }
...@@ -132,7 +132,7 @@ public class CompressTool { ...@@ -132,7 +132,7 @@ public class CompressTool {
int start = 1 + getLength(len); int start = 1 + getLength(len);
compress.expand(in, start, in.length - start, out, outPos, len); compress.expand(in, start, in.length - start, out, outPos, len);
} catch (Exception e) { } catch (Exception e) {
throw Message.getSQLException(ErrorCode.COMPRESSION_ERROR, null, e); throw Message.getSQLException(ErrorCode.COMPRESSION_ERROR, e);
} }
} }
......
...@@ -87,7 +87,7 @@ ShutdownHandler { ...@@ -87,7 +87,7 @@ ShutdownHandler {
* *
* @param args the command line arguments * @param args the command line arguments
*/ */
public static void main(String[] args) throws SQLException { public static void main(String... args) throws SQLException {
new Console().run(args); new Console().run(args);
} }
...@@ -98,7 +98,7 @@ ShutdownHandler { ...@@ -98,7 +98,7 @@ ShutdownHandler {
* *
* @param args the command line arguments * @param args the command line arguments
*/ */
public void run(String[] args) throws SQLException { public void run(String... args) throws SQLException {
isWindows = SysProperties.getStringSetting("os.name", "").startsWith("Windows"); isWindows = SysProperties.getStringSetting("os.name", "").startsWith("Windows");
boolean tcpStart = false, pgStart = false, webStart = false, toolStart = false; boolean tcpStart = false, pgStart = false, webStart = false, toolStart = false;
boolean browserStart = false; boolean browserStart = false;
...@@ -256,8 +256,8 @@ ShutdownHandler { ...@@ -256,8 +256,8 @@ ShutdownHandler {
try { try {
// SystemTray.isSupported(); // SystemTray.isSupported();
Boolean supported = (Boolean) Class.forName("java.awt.SystemTray"). Boolean supported = (Boolean) Class.forName("java.awt.SystemTray").
getMethod("isSupported", new Class[0]). getMethod("isSupported").
invoke(null, new Object[0]); invoke(null);
if (!supported.booleanValue()) { if (!supported.booleanValue()) {
return false; return false;
...@@ -282,30 +282,30 @@ ShutdownHandler { ...@@ -282,30 +282,30 @@ ShutdownHandler {
// SystemTray tray = SystemTray.getSystemTray(); // SystemTray tray = SystemTray.getSystemTray();
Object tray = Class.forName("java.awt.SystemTray"). Object tray = Class.forName("java.awt.SystemTray").
getMethod("getSystemTray", new Class[0]). getMethod("getSystemTray").
invoke(null, new Object[0]); invoke(null);
// Dimension d = tray.getTrayIconSize(); // Dimension d = tray.getTrayIconSize();
Dimension d = (Dimension) Class.forName("java.awt.SystemTray"). Dimension d = (Dimension) Class.forName("java.awt.SystemTray").
getMethod("getTrayIconSize", new Class[0]). getMethod("getTrayIconSize").
invoke(tray, new Object[0]); invoke(tray);
Image icon = (d.width >= 24 && d.height >= 24) ? icon24 : icon16; Image icon = (d.width >= 24 && d.height >= 24) ? icon24 : icon16;
// TrayIcon icon = new TrayIcon(image, "H2 Database Engine", menuConsole); // TrayIcon icon = new TrayIcon(image, "H2 Database Engine", menuConsole);
Object trayIcon = Class.forName("java.awt.TrayIcon"). Object trayIcon = Class.forName("java.awt.TrayIcon").
getConstructor(new Class[] { Image.class, String.class, PopupMenu.class }). getConstructor(Image.class, String.class, PopupMenu.class).
newInstance(new Object[] { icon, "H2 Database Engine", menuConsole }); newInstance(icon, "H2 Database Engine", menuConsole);
// trayIcon.addMouseListener(this); // trayIcon.addMouseListener(this);
trayIcon.getClass(). trayIcon.getClass().
getMethod("addMouseListener", new Class[]{MouseListener.class}). getMethod("addMouseListener", MouseListener.class).
invoke(trayIcon, new Object[]{this}); invoke(trayIcon, this);
// tray.add(icon); // tray.add(icon);
tray.getClass(). tray.getClass().
getMethod("add", new Class[] { Class.forName("java.awt.TrayIcon") }). getMethod("add", Class.forName("java.awt.TrayIcon")).
invoke(tray, new Object[] { trayIcon }); invoke(tray, trayIcon);
return true; return true;
} catch (Exception e) { } catch (Exception e) {
......
...@@ -72,11 +72,11 @@ public class ConvertTraceFile extends Tool { ...@@ -72,11 +72,11 @@ public class ConvertTraceFile extends Tool {
* *
* @param args the command line arguments * @param args the command line arguments
*/ */
public static void main(String[] args) throws SQLException { public static void main(String... args) throws SQLException {
new ConvertTraceFile().run(args); new ConvertTraceFile().run(args);
} }
public void run(String[] args) throws SQLException { public void run(String... args) throws SQLException {
String traceFile = "test.trace.db"; String traceFile = "test.trace.db";
String javaClass = "Test"; String javaClass = "Test";
String script = "test.sql"; String script = "test.sql";
...@@ -123,7 +123,7 @@ public class ConvertTraceFile extends Tool { ...@@ -123,7 +123,7 @@ public class ConvertTraceFile extends Tool {
cn = cn.substring(idx + 1); cn = cn.substring(idx + 1);
} }
javaWriter.println("public class " + cn + " {"); javaWriter.println("public class " + cn + " {");
javaWriter.println(" public static void main(String[] args) throws Exception {"); javaWriter.println(" public static void main(String... args) throws Exception {");
javaWriter.println(" Class.forName(\"org.h2.Driver\");"); javaWriter.println(" Class.forName(\"org.h2.Driver\");");
while (true) { while (true) {
String line = reader.readLine(); String line = reader.readLine();
......
...@@ -43,11 +43,11 @@ public class CreateCluster extends Tool { ...@@ -43,11 +43,11 @@ public class CreateCluster extends Tool {
* *
* @param args the command line arguments * @param args the command line arguments
*/ */
public static void main(String[] args) throws SQLException { public static void main(String... args) throws SQLException {
new CreateCluster().run(args); new CreateCluster().run(args);
} }
public void run(String[] args) throws SQLException { public void run(String... args) throws SQLException {
String urlSource = null; String urlSource = null;
String urlTarget = null; String urlTarget = null;
String user = "sa"; String user = "sa";
......
...@@ -39,11 +39,11 @@ public class DeleteDbFiles extends Tool { ...@@ -39,11 +39,11 @@ public class DeleteDbFiles extends Tool {
* *
* @param args the command line arguments * @param args the command line arguments
*/ */
public static void main(String[] args) throws SQLException { public static void main(String... args) throws SQLException {
new DeleteDbFiles().run(args); new DeleteDbFiles().run(args);
} }
public void run(String[] args) throws SQLException { public void run(String... args) throws SQLException {
String dir = "."; String dir = ".";
String db = null; String db = null;
boolean quiet = false; boolean quiet = false;
......
...@@ -100,7 +100,7 @@ public class Recover extends Tool implements DataHandler { ...@@ -100,7 +100,7 @@ public class Recover extends Tool implements DataHandler {
* *
* @param args the command line arguments * @param args the command line arguments
*/ */
public static void main(String[] args) throws SQLException { public static void main(String... args) throws SQLException {
new Recover().run(args); new Recover().run(args);
} }
...@@ -115,7 +115,7 @@ public class Recover extends Tool implements DataHandler { ...@@ -115,7 +115,7 @@ public class Recover extends Tool implements DataHandler {
* *
* @param args the command line arguments * @param args the command line arguments
*/ */
public void run(String[] args) throws SQLException { public void run(String... args) throws SQLException {
String dir = "."; String dir = ".";
String db = null; String db = null;
for (int i = 0; args != null && i < args.length; i++) { for (int i = 0; args != null && i < args.length; i++) {
......
...@@ -44,11 +44,11 @@ public class Restore extends Tool { ...@@ -44,11 +44,11 @@ public class Restore extends Tool {
* *
* @param args the command line arguments * @param args the command line arguments
*/ */
public static void main(String[] args) throws SQLException { public static void main(String... args) throws SQLException {
new Restore().run(args); new Restore().run(args);
} }
public void run(String[] args) throws SQLException { public void run(String... args) throws SQLException {
String zipFileName = "backup.zip"; String zipFileName = "backup.zip";
String dir = "."; String dir = ".";
String db = null; String db = null;
......
...@@ -62,7 +62,7 @@ public class RunScript extends Tool { ...@@ -62,7 +62,7 @@ public class RunScript extends Tool {
* *
* @param args the command line arguments * @param args the command line arguments
*/ */
public static void main(String[] args) throws SQLException { public static void main(String... args) throws SQLException {
new RunScript().run(args); new RunScript().run(args);
} }
...@@ -84,7 +84,7 @@ public class RunScript extends Tool { ...@@ -84,7 +84,7 @@ public class RunScript extends Tool {
* *
* @param args the command line arguments * @param args the command line arguments
*/ */
public void run(String[] args) throws SQLException { public void run(String... args) throws SQLException {
String url = null; String url = null;
String user = "sa"; String user = "sa";
String password = ""; String password = "";
......
...@@ -48,11 +48,11 @@ public class Script extends Tool { ...@@ -48,11 +48,11 @@ public class Script extends Tool {
* *
* @param args the command line arguments * @param args the command line arguments
*/ */
public static void main(String[] args) throws SQLException { public static void main(String... args) throws SQLException {
new Script().run(args); new Script().run(args);
} }
public void run(String[] args) throws SQLException { public void run(String... args) throws SQLException {
String url = null; String url = null;
String user = "sa"; String user = "sa";
String password = ""; String password = "";
......
...@@ -41,7 +41,7 @@ public class Server extends Tool implements Runnable, ShutdownHandler { ...@@ -41,7 +41,7 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
* @param service the service * @param service the service
* @param args the command line arguments * @param args the command line arguments
*/ */
public Server(Service service, String[] args) throws SQLException { public Server(Service service, String... args) throws SQLException {
this.service = service; this.service = service;
try { try {
service.init(args); service.init(args);
...@@ -98,11 +98,11 @@ public class Server extends Tool implements Runnable, ShutdownHandler { ...@@ -98,11 +98,11 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
* *
* @param args the command line arguments * @param args the command line arguments
*/ */
public static void main(String[] args) throws SQLException { public static void main(String... args) throws SQLException {
new Server().run(args); new Server().run(args);
} }
public void run(String[] args) throws SQLException { public void run(String... args) throws SQLException {
boolean tcpStart = false, pgStart = false, webStart = false; boolean tcpStart = false, pgStart = false, webStart = false;
boolean browserStart = false; boolean browserStart = false;
boolean tcpShutdown = false, tcpShutdownForce = false; boolean tcpShutdown = false, tcpShutdownForce = false;
...@@ -298,7 +298,7 @@ public class Server extends Tool implements Runnable, ShutdownHandler { ...@@ -298,7 +298,7 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
* @param args the argument list * @param args the argument list
* @return the server * @return the server
*/ */
public static Server createWebServer(String[] args) throws SQLException { public static Server createWebServer(String... args) throws SQLException {
WebServer service = new WebServer(); WebServer service = new WebServer();
Server server = new Server(service, args); Server server = new Server(service, args);
service.setShutdownHandler(server); service.setShutdownHandler(server);
...@@ -316,7 +316,7 @@ public class Server extends Tool implements Runnable, ShutdownHandler { ...@@ -316,7 +316,7 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
* @param args the argument list * @param args the argument list
* @return the server * @return the server
*/ */
public static Server createTcpServer(String[] args) throws SQLException { public static Server createTcpServer(String... args) throws SQLException {
return new Server(new TcpServer(), args); return new Server(new TcpServer(), args);
} }
...@@ -325,14 +325,13 @@ public class Server extends Tool implements Runnable, ShutdownHandler { ...@@ -325,14 +325,13 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
* Example: * Example:
* <pre> * <pre>
* Server server = * Server server =
* Server.createPgServer(new String[]{ * Server.createPgServer("-pgAllowOthers").start();
* "-pgAllowOthers"}).start();
* </pre> * </pre>
* *
* @param args the argument list * @param args the argument list
* @return the server * @return the server
*/ */
public static Server createPgServer(String[] args) throws SQLException { public static Server createPgServer(String... args) throws SQLException {
return new Server(new PgServer(), args); return new Server(new PgServer(), args);
} }
...@@ -356,7 +355,7 @@ public class Server extends Tool implements Runnable, ShutdownHandler { ...@@ -356,7 +355,7 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
if (isRunning(true)) { if (isRunning(true)) {
return this; return this;
} }
throw Message.getSQLException(ErrorCode.EXCEPTION_OPENING_PORT_2, new String[] { name, "timeout" }); throw Message.getSQLException(ErrorCode.EXCEPTION_OPENING_PORT_2, name, "timeout");
} }
private static void wait(int i) { private static void wait(int i) {
......
...@@ -65,7 +65,7 @@ public class Shell extends Tool { ...@@ -65,7 +65,7 @@ public class Shell extends Tool {
* *
* @param args the command line arguments * @param args the command line arguments
*/ */
public static void main(String[] args) throws SQLException { public static void main(String... args) throws SQLException {
new Shell().run(args); new Shell().run(args);
} }
...@@ -101,7 +101,7 @@ public class Shell extends Tool { ...@@ -101,7 +101,7 @@ public class Shell extends Tool {
* *
* @param args the command line settings * @param args the command line settings
*/ */
public void run(String[] args) throws SQLException { public void run(String... args) throws SQLException {
String url = null; String url = null;
String user = ""; String user = "";
String password = ""; String password = "";
...@@ -348,11 +348,11 @@ public class Shell extends Tool { ...@@ -348,11 +348,11 @@ public class Shell extends Tool {
private String readPassword() throws IOException { private String readPassword() throws IOException {
try { try {
Method getConsole = System.class.getMethod("console", new Class[0]); Method getConsole = System.class.getMethod("console");
Object console = getConsole.invoke(null, (Object[]) null); Object console = getConsole.invoke(null);
Method readPassword = console.getClass().getMethod("readPassword", new Class[0]); Method readPassword = console.getClass().getMethod("readPassword");
print("Password "); print("Password ");
char[] password = (char[]) readPassword.invoke(console, (Object[]) null); char[] password = (char[]) readPassword.invoke(console);
return password == null ? null : new String(password); return password == null ? null : new String(password);
} catch (Exception e) { } catch (Exception e) {
// ignore, use the default solution // ignore, use the default solution
......
...@@ -47,8 +47,8 @@ import java.sql.SQLXML; ...@@ -47,8 +47,8 @@ import java.sql.SQLXML;
* SimpleResultSet rs = new SimpleResultSet(); * SimpleResultSet rs = new SimpleResultSet();
* rs.addColumn(&quot;ID&quot;, Types.INTEGER, 10, 0); * rs.addColumn(&quot;ID&quot;, Types.INTEGER, 10, 0);
* rs.addColumn(&quot;NAME&quot;, Types.VARCHAR, 255, 0); * rs.addColumn(&quot;NAME&quot;, Types.VARCHAR, 255, 0);
* rs.addRow(new Object[] { new Integer(0), &quot;Hello&quot; }); * rs.addRow(0, &quot;Hello&quot; });
* rs.addRow(new Object[] { new Integer(1), &quot;World&quot; }); * rs.addRow(1, &quot;World&quot; });
* </pre> * </pre>
* *
*/ */
...@@ -249,7 +249,7 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData { ...@@ -249,7 +249,7 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
* *
* @param row the row as an array of objects * @param row the row as an array of objects
*/ */
public void addRow(Object[] row) throws SQLException { public void addRow(Object... row) throws SQLException {
if (rows == null) { if (rows == null) {
throw new SQLException("Cannot add a row when using RowSource", "21S02"); throw new SQLException("Cannot add a row when using RowSource", "21S02");
} }
......
...@@ -80,9 +80,9 @@ public class ClassUtils { ...@@ -80,9 +80,9 @@ public class ClassUtils {
try { try {
return Class.forName(className); return Class.forName(className);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
throw Message.getSQLException(ErrorCode.CLASS_NOT_FOUND_1, new String[] { className }, e); throw Message.getSQLException(ErrorCode.CLASS_NOT_FOUND_1, e, className);
} catch (NoClassDefFoundError e) { } catch (NoClassDefFoundError e) {
throw Message.getSQLException(ErrorCode.CLASS_NOT_FOUND_1, new String[] { className }, e); throw Message.getSQLException(ErrorCode.CLASS_NOT_FOUND_1, e, className);
} }
} }
...@@ -101,8 +101,8 @@ public class ClassUtils { ...@@ -101,8 +101,8 @@ public class ClassUtils {
return false; return false;
} }
try { try {
Method isVarArgs = m.getClass().getMethod("isVarArgs", new Class[0]); Method isVarArgs = m.getClass().getMethod("isVarArgs");
Boolean result = (Boolean) isVarArgs.invoke(m, new Object[0]); Boolean result = (Boolean) isVarArgs.invoke(m);
return result.booleanValue(); return result.booleanValue();
} catch (Exception e) { } catch (Exception e) {
return false; return false;
......
...@@ -251,7 +251,7 @@ public class DateTimeUtils { ...@@ -251,7 +251,7 @@ public class DateTimeUtils {
int s1 = s.indexOf('-', 1); int s1 = s.indexOf('-', 1);
int s2 = s.indexOf('-', s1 + 1); int s2 = s.indexOf('-', s1 + 1);
if (s1 <= 0 || s2 <= s1) { if (s1 <= 0 || s2 <= s1) {
throw Message.getSQLException(errorCode, new String[] { s, "format yyyy-mm-dd" }); throw Message.getSQLException(errorCode, s, "format yyyy-mm-dd");
} }
year = Integer.parseInt(s.substring(0, s1)); year = Integer.parseInt(s.substring(0, s1));
month = Integer.parseInt(s.substring(s1 + 1, s2)); month = Integer.parseInt(s.substring(s1 + 1, s2));
...@@ -264,7 +264,7 @@ public class DateTimeUtils { ...@@ -264,7 +264,7 @@ public class DateTimeUtils {
int s2 = s.indexOf(':', s1 + 1); int s2 = s.indexOf(':', s1 + 1);
int s3 = s.indexOf('.', s2 + 1); int s3 = s.indexOf('.', s2 + 1);
if (s1 <= 0 || s2 <= s1) { if (s1 <= 0 || s2 <= s1) {
throw Message.getSQLException(errorCode, new String[] { s, "format hh:mm:ss" }); throw Message.getSQLException(errorCode, s, "format hh:mm:ss");
} }
if (s.endsWith("Z")) { if (s.endsWith("Z")) {
...@@ -340,7 +340,7 @@ public class DateTimeUtils { ...@@ -340,7 +340,7 @@ public class DateTimeUtils {
throw Message.throwInternalError("type:" + type); throw Message.throwInternalError("type:" + type);
} }
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
throw Message.getSQLException(errorCode, new String[]{original, e.toString()}, e); throw Message.getSQLException(errorCode, e, original, e.toString());
} }
} }
......
...@@ -159,7 +159,7 @@ public class NetUtils { ...@@ -159,7 +159,7 @@ public class NetUtils {
return new ServerSocket(port, 0, bindAddress); return new ServerSocket(port, 0, bindAddress);
} catch (BindException be) { } catch (BindException be) {
throw Message.getSQLException(ErrorCode.EXCEPTION_OPENING_PORT_2, throw Message.getSQLException(ErrorCode.EXCEPTION_OPENING_PORT_2,
new String[] { "" + port, be.toString() }, be); be, "" + port, be.toString());
} catch (IOException e) { } catch (IOException e) {
throw Message.convertIOException(e, "port: " + port + " ssl: " + ssl); throw Message.convertIOException(e, "port: " + port + " ssl: " + ssl);
} }
......
...@@ -45,7 +45,7 @@ public class ObjectUtils { ...@@ -45,7 +45,7 @@ public class ObjectUtils {
os.writeObject(obj); os.writeObject(obj);
return out.toByteArray(); return out.toByteArray();
} catch (Throwable e) { } catch (Throwable e) {
throw Message.getSQLException(ErrorCode.SERIALIZATION_FAILED_1, new String[] { e.toString() }, e); throw Message.getSQLException(ErrorCode.SERIALIZATION_FAILED_1, e, e.toString());
} }
} }
...@@ -63,7 +63,7 @@ public class ObjectUtils { ...@@ -63,7 +63,7 @@ public class ObjectUtils {
Object obj = is.readObject(); Object obj = is.readObject();
return obj; return obj;
} catch (Throwable e) { } catch (Throwable e) {
throw Message.getSQLException(ErrorCode.DESERIALIZATION_FAILED_1, new String[] { e.toString() }, e); throw Message.getSQLException(ErrorCode.DESERIALIZATION_FAILED_1, e, e.toString());
} }
} }
......
...@@ -106,9 +106,9 @@ public class RandomUtils { ...@@ -106,9 +106,9 @@ public class RandomUtils {
// nanoseconds if available // nanoseconds if available
try { try {
Method m = System.class.getMethod("nanoTime", new Class[0]); Method m = System.class.getMethod("nanoTime");
if (m != null) { if (m != null) {
Object o = m.invoke(null, (java.lang.Object[]) null); Object o = m.invoke(null);
out.writeUTF(o.toString()); out.writeUTF(o.toString());
} }
} catch (Exception e) { } catch (Exception e) {
...@@ -133,17 +133,13 @@ public class RandomUtils { ...@@ -133,17 +133,13 @@ public class RandomUtils {
try { try {
// workaround for the Google App Engine: don't use InetAddress // workaround for the Google App Engine: don't use InetAddress
Class< ? > inetAddressClass = Class.forName("java.net.InetAddress"); Class< ? > inetAddressClass = Class.forName("java.net.InetAddress");
Object localHost = inetAddressClass.getMethod( Object localHost = inetAddressClass.getMethod("getLocalHost").invoke(null);
"getLocalHost", new Class[0]).invoke(null, new Object[0]); String hostName = inetAddressClass.getMethod("getHostName").invoke(localHost).toString();
String hostName = inetAddressClass.getMethod(
"getHostName", new Class[0]).invoke(localHost, new Object[0]).toString();
out.writeUTF(hostName); out.writeUTF(hostName);
Object[] list = (Object[]) inetAddressClass.getMethod( Object[] list = (Object[]) inetAddressClass.getMethod("getAllByName", String.class).invoke(null, hostName);
"getAllByName", new Class[] { String.class }) Method getAddress = inetAddressClass.getMethod("getAddress");
.invoke(null, new Object[] { hostName });
Method getAddress = inetAddressClass.getMethod("getAddress", new Class[0]);
for (Object o : list) { for (Object o : list) {
out.write((byte[]) getAddress.invoke(o, new Object[0])); out.write((byte[]) getAddress.invoke(o));
} }
} catch (Throwable e) { } catch (Throwable e) {
// on some system, InetAddress is not supported // on some system, InetAddress is not supported
......
...@@ -49,16 +49,16 @@ public class StartBrowser { ...@@ -49,16 +49,16 @@ public class StartBrowser {
Class< ? > desktopClass = Class.forName("java.awt.Desktop"); Class< ? > desktopClass = Class.forName("java.awt.Desktop");
// Desktop.isDesktopSupported() // Desktop.isDesktopSupported()
Boolean supported = (Boolean) desktopClass. Boolean supported = (Boolean) desktopClass.
getMethod("isDesktopSupported", new Class[0]). getMethod("isDesktopSupported").
invoke(null, new Object[0]); invoke(null, new Object[0]);
URI uri = new URI(url); URI uri = new URI(url);
if (supported.booleanValue()) { if (supported.booleanValue()) {
// Desktop.getDesktop(); // Desktop.getDesktop();
Object desktop = desktopClass.getMethod("getDesktop", new Class[0]). Object desktop = desktopClass.getMethod("getDesktop").
invoke(null, new Object[0]); invoke(null, new Object[0]);
// desktop.browse(uri); // desktop.browse(uri);
desktopClass.getMethod("browse", new Class[] { URI.class }). desktopClass.getMethod("browse", URI.class).
invoke(desktop, new Object[] { uri }); invoke(desktop, uri);
return; return;
} }
} catch (Exception e) { } catch (Exception e) {
......
...@@ -530,7 +530,7 @@ public class StringUtils { ...@@ -530,7 +530,7 @@ public class StringUtils {
return dateFormat.parse(date); return dateFormat.parse(date);
} }
} catch (ParseException e) { } catch (ParseException e) {
throw Message.getSQLException(ErrorCode.PARSE_ERROR_1, new String[]{date}, e); throw Message.getSQLException(ErrorCode.PARSE_ERROR_1, e, date);
} }
} }
...@@ -555,7 +555,7 @@ public class StringUtils { ...@@ -555,7 +555,7 @@ public class StringUtils {
} }
return df; return df;
} catch (Exception e) { } catch (Exception e) {
throw Message.getSQLException(ErrorCode.PARSE_ERROR_1, new String []{format + "/" + locale + "/" + timeZone}, e); throw Message.getSQLException(ErrorCode.PARSE_ERROR_1, e, format + "/" + locale + "/" + timeZone);
} }
} }
......
...@@ -40,7 +40,7 @@ public abstract class Tool { ...@@ -40,7 +40,7 @@ public abstract class Tool {
* *
* @param args the argument list * @param args the argument list
*/ */
public abstract void run(String[] args) throws SQLException; public abstract void run(String... args) throws SQLException;
/** /**
* Throw a SQLException saying this command line option is not supported. * Throw a SQLException saying this command line option is not supported.
......
...@@ -772,7 +772,7 @@ public abstract class Value { ...@@ -772,7 +772,7 @@ public abstract class Value {
case RESULT_SET: { case RESULT_SET: {
SimpleResultSet rs = new SimpleResultSet(); SimpleResultSet rs = new SimpleResultSet();
rs.addColumn("X", Types.VARCHAR, s.length(), 0); rs.addColumn("X", Types.VARCHAR, s.length(), 0);
rs.addRow(new String[]{s}); rs.addRow(s);
return ValueResultSet.get(rs); return ValueResultSet.get(rs);
} }
case UUID: case UUID:
...@@ -781,7 +781,7 @@ public abstract class Value { ...@@ -781,7 +781,7 @@ public abstract class Value {
throw Message.throwInternalError("type=" + type); throw Message.throwInternalError("type=" + type);
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throw Message.getSQLException(ErrorCode.DATA_CONVERSION_ERROR_1, new String[] { s }, e); throw Message.getSQLException(ErrorCode.DATA_CONVERSION_ERROR_1, e, s);
} }
} }
......
...@@ -49,8 +49,8 @@ public class ValueDecimal extends Value { ...@@ -49,8 +49,8 @@ public class ValueDecimal extends Value {
if (value == null) { if (value == null) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} else if (!SysProperties.ALLOW_BIG_DECIMAL_EXTENSIONS && !value.getClass().equals(BigDecimal.class)) { } else if (!SysProperties.ALLOW_BIG_DECIMAL_EXTENSIONS && !value.getClass().equals(BigDecimal.class)) {
SQLException e = Message.getSQLException(ErrorCode.INVALID_CLASS_2, new String[] { SQLException e = Message.getSQLException(ErrorCode.INVALID_CLASS_2,
BigDecimal.class.getName(), value.getClass().getName() }); BigDecimal.class.getName(), value.getClass().getName());
throw Message.convertToInternal(e); throw Message.convertToInternal(e);
} }
this.value = value; this.value = value;
......
...@@ -28,7 +28,7 @@ public class Compact { ...@@ -28,7 +28,7 @@ public class Compact {
* *
* @param args the command line parameters * @param args the command line parameters
*/ */
public static void main(String[] args) throws Exception { public static void main(String... args) throws Exception {
DeleteDbFiles.execute("data", "test", true); DeleteDbFiles.execute("data", "test", true);
Class.forName("org.h2.Driver"); Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection("jdbc:h2:data/test", "sa", ""); Connection conn = DriverManager.getConnection("jdbc:h2:data/test", "sa", "");
......
...@@ -28,7 +28,7 @@ public class CsvSample { ...@@ -28,7 +28,7 @@ public class CsvSample {
* *
* @param args the command line parameters * @param args the command line parameters
*/ */
public static void main(String[] args) throws SQLException { public static void main(String... args) throws SQLException {
CsvSample.write(); CsvSample.write();
CsvSample.read(); CsvSample.read();
} }
...@@ -41,8 +41,8 @@ public class CsvSample { ...@@ -41,8 +41,8 @@ public class CsvSample {
rs.addColumn("NAME", Types.VARCHAR, 255, 0); rs.addColumn("NAME", Types.VARCHAR, 255, 0);
rs.addColumn("EMAIL", Types.VARCHAR, 255, 0); rs.addColumn("EMAIL", Types.VARCHAR, 255, 0);
rs.addColumn("PHONE", Types.VARCHAR, 255, 0); rs.addColumn("PHONE", Types.VARCHAR, 255, 0);
rs.addRow(new String[] { "Bob Meier", "bob.meier@abcde.abc", "+41123456789" }); rs.addRow("Bob Meier", "bob.meier@abcde.abc", "+41123456789");
rs.addRow(new String[] { "John Jones", "john.jones@abcde.abc", "+41976543210" }); rs.addRow("John Jones", "john.jones@abcde.abc", "+41976543210");
Csv.getInstance().write("data/test.csv", rs, null); Csv.getInstance().write("data/test.csv", rs, null);
} }
......
...@@ -25,7 +25,7 @@ public class FileFunctions { ...@@ -25,7 +25,7 @@ public class FileFunctions {
* *
* @param args the command line parameters * @param args the command line parameters
*/ */
public static void main(String[] args) throws Exception { public static void main(String... args) throws Exception {
Class.forName("org.h2.Driver"); Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection("jdbc:h2:mem:", "sa", ""); Connection conn = DriverManager.getConnection("jdbc:h2:mem:", "sa", "");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
......
...@@ -28,7 +28,7 @@ public class Function { ...@@ -28,7 +28,7 @@ public class Function {
* *
* @param args the command line parameters * @param args the command line parameters
*/ */
public static void main(String[] args) throws Exception { public static void main(String... args) throws Exception {
Class.forName("org.h2.Driver"); Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection("jdbc:h2:mem:", "sa", ""); Connection conn = DriverManager.getConnection("jdbc:h2:mem:", "sa", "");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
...@@ -103,7 +103,7 @@ public class Function { ...@@ -103,7 +103,7 @@ public class Function {
SimpleResultSet rs = new SimpleResultSet(); SimpleResultSet rs = new SimpleResultSet();
rs.addColumn("ID", Types.INTEGER, 10, 0); rs.addColumn("ID", Types.INTEGER, 10, 0);
rs.addColumn("NAME", Types.VARCHAR, 255, 0); rs.addColumn("NAME", Types.VARCHAR, 255, 0);
rs.addRow(new Object[] { new Integer(0), "Hello" }); rs.addRow(0, "Hello");
return rs; return rs;
} }
...@@ -125,8 +125,7 @@ public class Function { ...@@ -125,8 +125,7 @@ public class Function {
} }
for (int s = size.intValue(), x = 0; x < s; x++) { for (int s = size.intValue(), x = 0; x < s; x++) {
for (int y = 0; y < s; y++) { for (int y = 0; y < s; y++) {
rs.addRow(new Object[] { rs.addRow(x, y);
new Integer(x), new Integer(y) });
} }
} }
return rs; return rs;
......
...@@ -30,7 +30,7 @@ public class FunctionMultiReturn { ...@@ -30,7 +30,7 @@ public class FunctionMultiReturn {
* *
* @param args the command line parameters * @param args the command line parameters
*/ */
public static void main(String[] args) throws Exception { public static void main(String... args) throws Exception {
Class.forName("org.h2.Driver"); Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection("jdbc:h2:mem:", "sa", ""); Connection conn = DriverManager.getConnection("jdbc:h2:mem:", "sa", "");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
...@@ -97,7 +97,7 @@ public class FunctionMultiReturn { ...@@ -97,7 +97,7 @@ public class FunctionMultiReturn {
if (r != null && alpha != null) { if (r != null && alpha != null) {
double x = r.doubleValue() * Math.cos(alpha.doubleValue()); double x = r.doubleValue() * Math.cos(alpha.doubleValue());
double y = r.doubleValue() * Math.sin(alpha.doubleValue()); double y = r.doubleValue() * Math.sin(alpha.doubleValue());
rs.addRow(new Object[] { new Double(x), new Double(y) }); rs.addRow(x, y);
} }
return rs; return rs;
} }
...@@ -139,7 +139,7 @@ public class FunctionMultiReturn { ...@@ -139,7 +139,7 @@ public class FunctionMultiReturn {
double alpha = rs.getDouble("A"); double alpha = rs.getDouble("A");
double x = r * Math.cos(alpha); double x = r * Math.cos(alpha);
double y = r * Math.sin(alpha); double y = r * Math.sin(alpha);
result.addRow(new Object[] { new Double(r), new Double(alpha), new Double(x), new Double(y) }); result.addRow(r, alpha, x, y);
} }
} }
return result; return result;
......
...@@ -27,7 +27,7 @@ public class InitDatabaseFromJar { ...@@ -27,7 +27,7 @@ public class InitDatabaseFromJar {
* *
* @param args the command line parameters * @param args the command line parameters
*/ */
public static void main(String[] args) throws Exception { public static void main(String... args) throws Exception {
new InitDatabaseFromJar().createScript(); new InitDatabaseFromJar().createScript();
new InitDatabaseFromJar().initDb(); new InitDatabaseFromJar().initDb();
} }
......
...@@ -25,10 +25,10 @@ public class MixedMode { ...@@ -25,10 +25,10 @@ public class MixedMode {
* *
* @param args the command line parameters * @param args the command line parameters
*/ */
public static void main(String[] args) throws Exception { public static void main(String... args) throws Exception {
// start the server, allows to access the database remotely // start the server, allows to access the database remotely
Server server = Server.createTcpServer(new String[] { "-tcpPort", "9081" }); Server server = Server.createTcpServer("-tcpPort", "9081");
server.start(); server.start();
System.out.println("You can access the database remotely now, using the URL:"); System.out.println("You can access the database remotely now, using the URL:");
System.out.println("jdbc:h2:tcp://localhost:9081/~/test (user: sa, password: sa)"); System.out.println("jdbc:h2:tcp://localhost:9081/~/test (user: sa, password: sa)");
......
...@@ -32,7 +32,7 @@ public class Newsfeed { ...@@ -32,7 +32,7 @@ public class Newsfeed {
* *
* @param args the command line parameters * @param args the command line parameters
*/ */
public static void main(String[] args) throws Exception { public static void main(String... args) throws Exception {
String targetDir = args.length == 0 ? "." : args[0]; String targetDir = args.length == 0 ? "." : args[0];
Class.forName("org.h2.Driver"); Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection("jdbc:h2:mem:", "sa", ""); Connection conn = DriverManager.getConnection("jdbc:h2:mem:", "sa", "");
......
...@@ -32,7 +32,7 @@ public class SQLInjection { ...@@ -32,7 +32,7 @@ public class SQLInjection {
* *
* @param args the command line parameters * @param args the command line parameters
*/ */
public static void main(String[] args) throws Exception { public static void main(String... args) throws Exception {
new SQLInjection().run("org.h2.Driver", new SQLInjection().run("org.h2.Driver",
"jdbc:h2:test", "sa", "sa"); "jdbc:h2:test", "sa", "sa");
// new SQLInjection().run("org.postgresql.Driver", // new SQLInjection().run("org.postgresql.Driver",
......
...@@ -25,7 +25,7 @@ public class SecurePassword { ...@@ -25,7 +25,7 @@ public class SecurePassword {
* *
* @param args the command line parameters * @param args the command line parameters
*/ */
public static void main(String[] args) throws Exception { public static void main(String... args) throws Exception {
Class.forName("org.h2.Driver"); Class.forName("org.h2.Driver");
String url = "jdbc:h2:data/simple"; String url = "jdbc:h2:data/simple";
......
...@@ -37,7 +37,7 @@ public class ShowProgress implements DatabaseEventListener { ...@@ -37,7 +37,7 @@ public class ShowProgress implements DatabaseEventListener {
* *
* @param args the command line parameters * @param args the command line parameters
*/ */
public static void main(String[] args) throws Exception { public static void main(String... args) throws Exception {
new ShowProgress().test(); new ShowProgress().test();
} }
......
...@@ -18,7 +18,7 @@ public class ShutdownServer { ...@@ -18,7 +18,7 @@ public class ShutdownServer {
* *
* @param args the command line parameters * @param args the command line parameters
*/ */
public static void main(String[] args) throws Exception { public static void main(String... args) throws Exception {
org.h2.tools.Server.shutdownTcpServer("tcp://localhost:9094", "", false); org.h2.tools.Server.shutdownTcpServer("tcp://localhost:9094", "", false);
} }
} }
...@@ -27,7 +27,7 @@ public class TriggerSample { ...@@ -27,7 +27,7 @@ public class TriggerSample {
* *
* @param args the command line parameters * @param args the command line parameters
*/ */
public static void main(String[] args) throws Exception { public static void main(String... args) throws Exception {
Class.forName("org.h2.Driver"); Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection("jdbc:h2:mem:", "sa", ""); Connection conn = DriverManager.getConnection("jdbc:h2:mem:", "sa", "");
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
......
...@@ -278,14 +278,14 @@ java org.h2.test.TestAll timer ...@@ -278,14 +278,14 @@ java org.h2.test.TestAll timer
* *
* @param args the command line arguments * @param args the command line arguments
*/ */
public static void main(String[] args) throws Exception { public static void main(String... args) throws Exception {
OutputCatcher catcher = OutputCatcher.start(); OutputCatcher catcher = OutputCatcher.start();
run(args); run(args);
catcher.stop(); catcher.stop();
catcher.writeTo("Test Output", "docs/html/testOutput.html"); catcher.writeTo("Test Output", "docs/html/testOutput.html");
} }
private static void run(String[] args) throws Exception { private static void run(String... args) throws Exception {
SelfDestructor.startCountdown(6 * 60); SelfDestructor.startCountdown(6 * 60);
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
TestAll test = new TestAll(); TestAll test = new TestAll();
...@@ -293,16 +293,12 @@ java org.h2.test.TestAll timer ...@@ -293,16 +293,12 @@ java org.h2.test.TestAll timer
System.setProperty("h2.maxMemoryRowsDistinct", "128"); System.setProperty("h2.maxMemoryRowsDistinct", "128");
System.setProperty("h2.check2", "true"); System.setProperty("h2.check2", "true");
int test2;
//System.setProperty("h2.optimizeInList", "true");
/* /*
OPTIMIZE_IN_LIST improve LIKE performance
use ... parameters (main, Message.getSQLException, trace?) System.setProperty("h2.optimizeInList", "true");
H2 Console: if number of items is low (calculate that first), display data types, otherwise not.
Always display indexes and views in all schemas.
------------- -------------
create a short documentation create a short documentation
...@@ -347,12 +343,12 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1` ...@@ -347,12 +343,12 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
System.setProperty(SysProperties.H2_PAGE_STORE, "true"); System.setProperty(SysProperties.H2_PAGE_STORE, "true");
test.pageStore = true; test.pageStore = true;
test.runTests(); test.runTests();
TestPerformance.main(new String[]{ "-init", "-db", "1"}); TestPerformance.main("-init", "-db", "1");
System.setProperty(SysProperties.H2_PAGE_STORE, "false"); System.setProperty(SysProperties.H2_PAGE_STORE, "false");
test.pageStore = false; test.pageStore = false;
test.runTests(); test.runTests();
TestPerformance.main(new String[]{ "-init", "-db", "1"}); TestPerformance.main("-init", "-db", "1");
} }
System.out.println(TestBase.formatTime(System.currentTimeMillis() - time) + " total"); System.out.println(TestBase.formatTime(System.currentTimeMillis() - time) + " total");
} }
......
...@@ -90,11 +90,11 @@ class Database { ...@@ -90,11 +90,11 @@ class Database {
*/ */
void startServer() throws Exception { void startServer() throws Exception {
if (url.startsWith("jdbc:h2:tcp:")) { if (url.startsWith("jdbc:h2:tcp:")) {
serverH2 = Server.createTcpServer(new String[0]).start(); serverH2 = Server.createTcpServer().start();
Thread.sleep(100); Thread.sleep(100);
} else if (url.startsWith("jdbc:derby://")) { } else if (url.startsWith("jdbc:derby://")) {
serverDerby = Class.forName("org.apache.derby.drda.NetworkServerControl").newInstance(); serverDerby = Class.forName("org.apache.derby.drda.NetworkServerControl").newInstance();
Method m = serverDerby.getClass().getMethod("start", new Class[] { PrintWriter.class }); Method m = serverDerby.getClass().getMethod("start", PrintWriter.class);
m.invoke(serverDerby, new Object[] { null }); m.invoke(serverDerby, new Object[] { null });
// serverDerby = new NetworkServerControl(); // serverDerby = new NetworkServerControl();
// serverDerby.start(null); // serverDerby.start(null);
...@@ -102,7 +102,7 @@ class Database { ...@@ -102,7 +102,7 @@ class Database {
} else if (url.startsWith("jdbc:hsqldb:hsql:")) { } else if (url.startsWith("jdbc:hsqldb:hsql:")) {
if (!serverHSQLDB) { if (!serverHSQLDB) {
Class< ? > c = Class.forName("org.hsqldb.Server"); Class< ? > c = Class.forName("org.hsqldb.Server");
Method m = c.getMethod("main", new Class[] { String[].class }); Method m = c.getMethod("main", String[].class);
m.invoke(null, new Object[] { new String[] { "-database.0", m.invoke(null, new Object[] { new String[] { "-database.0",
"data/mydb;hsqldb.default_table_type=cached", "-dbname.0", "xdb" } }); "data/mydb;hsqldb.default_table_type=cached", "-dbname.0", "xdb" } });
// org.hsqldb.Server.main(new String[]{"-database.0", "mydb", // org.hsqldb.Server.main(new String[]{"-database.0", "mydb",
...@@ -122,7 +122,7 @@ class Database { ...@@ -122,7 +122,7 @@ class Database {
serverH2 = null; serverH2 = null;
} }
if (serverDerby != null) { if (serverDerby != null) {
Method m = serverDerby.getClass().getMethod("shutdown", new Class[] {}); Method m = serverDerby.getClass().getMethod("shutdown");
// cast for JDK 1.5 // cast for JDK 1.5
m.invoke(serverDerby, (Object[]) null); m.invoke(serverDerby, (Object[]) null);
// serverDerby.shutdown(); // serverDerby.shutdown();
......
...@@ -45,7 +45,7 @@ public class TestPerformance { ...@@ -45,7 +45,7 @@ public class TestPerformance {
* *
* @param args the command line parameters * @param args the command line parameters
*/ */
public static void main(String[] args) throws Exception { public static void main(String... args) throws Exception {
new TestPerformance().test(args); new TestPerformance().test(args);
} }
...@@ -68,7 +68,7 @@ public class TestPerformance { ...@@ -68,7 +68,7 @@ public class TestPerformance {
} }
} }
private void test(String[] args) throws Exception { private void test(String... args) throws Exception {
int dbId = -1; int dbId = -1;
boolean exit = false; boolean exit = false;
String out = "benchmark.html"; String out = "benchmark.html";
......
...@@ -57,11 +57,11 @@ public class Coverage { ...@@ -57,11 +57,11 @@ public class Coverage {
* *
* @param args the command line parameters * @param args the command line parameters
*/ */
public static void main(String[] args) { public static void main(String... args) {
new Coverage().run(args); new Coverage().run(args);
} }
private void run(String[] args) { private void run(String... args) {
if (args.length == 0 || args[0].equals("-?")) { if (args.length == 0 || args[0].equals("-?")) {
printUsage(); printUsage();
return; return;
......
...@@ -22,7 +22,7 @@ public abstract class Task { ...@@ -22,7 +22,7 @@ public abstract class Task {
* *
* @param args the command line arguments * @param args the command line arguments
*/ */
public static void main(String[] args) { public static void main(String... args) {
SelfDestructor.startCountdown(60); SelfDestructor.startCountdown(60);
Task task; Task task;
try { try {
...@@ -49,7 +49,7 @@ public abstract class Task { ...@@ -49,7 +49,7 @@ public abstract class Task {
* *
* @param args the command line arguments * @param args the command line arguments
*/ */
abstract void run(String[] args) throws Exception; abstract void run(String... args) throws Exception;
/** /**
* Receive a message from the process over the standard output. * Receive a message from the process over the standard output.
......
...@@ -44,7 +44,7 @@ public class TaskProcess { ...@@ -44,7 +44,7 @@ public class TaskProcess {
* *
* @param args the arguments, or null * @param args the arguments, or null
*/ */
public void start(String[] args) { public void start(String... args) {
try { try {
String selfDestruct = SelfDestructor.getPropertyString(60); String selfDestruct = SelfDestructor.getPropertyString(60);
ArrayList<String> list = new ArrayList<String>(); ArrayList<String> list = new ArrayList<String>();
......
...@@ -27,7 +27,7 @@ public class TestAlter extends TestBase { ...@@ -27,7 +27,7 @@ public class TestAlter extends TestBase {
* *
* @param a ignored * @param a ignored
*/ */
public static void main(String[] a) throws Exception { public static void main(String... a) throws Exception {
TestBase.createCaller().init().test(); TestBase.createCaller().init().test();
} }
......
...@@ -23,7 +23,7 @@ public class TestAutoRecompile extends TestBase { ...@@ -23,7 +23,7 @@ public class TestAutoRecompile extends TestBase {
* *
* @param a ignored * @param a ignored
*/ */
public static void main(String[] a) throws Exception { public static void main(String... a) throws Exception {
TestBase.createCaller().init().test(); TestBase.createCaller().init().test();
} }
......
...@@ -25,7 +25,7 @@ public class TestBackup extends TestBase { ...@@ -25,7 +25,7 @@ public class TestBackup extends TestBase {
* *
* @param a ignored * @param a ignored
*/ */
public static void main(String[] a) throws Exception { public static void main(String... a) throws Exception {
TestBase.createCaller().init().test(); TestBase.createCaller().init().test();
} }
......
...@@ -25,7 +25,7 @@ public class TestBigDb extends TestBase { ...@@ -25,7 +25,7 @@ public class TestBigDb extends TestBase {
* *
* @param a ignored * @param a ignored
*/ */
public static void main(String[] a) throws Exception { public static void main(String... a) throws Exception {
TestBase.createCaller().init().test(); TestBase.createCaller().init().test();
} }
......
...@@ -26,7 +26,7 @@ public class TestBigResult extends TestBase { ...@@ -26,7 +26,7 @@ public class TestBigResult extends TestBase {
* *
* @param a ignored * @param a ignored
*/ */
public static void main(String[] a) throws Exception { public static void main(String... a) throws Exception {
TestBase.createCaller().init().test(); TestBase.createCaller().init().test();
} }
......
...@@ -30,7 +30,7 @@ public class TestCases extends TestBase { ...@@ -30,7 +30,7 @@ public class TestCases extends TestBase {
* *
* @param a ignored * @param a ignored
*/ */
public static void main(String[] a) throws Exception { public static void main(String... a) throws Exception {
TestBase.createCaller().init().test(); TestBase.createCaller().init().test();
} }
......
...@@ -22,7 +22,7 @@ public class TestCheckpoint extends TestBase { ...@@ -22,7 +22,7 @@ public class TestCheckpoint extends TestBase {
* *
* @param a ignored * @param a ignored
*/ */
public static void main(String[] a) throws Exception { public static void main(String... a) throws Exception {
TestBase.createCaller().init().test(); TestBase.createCaller().init().test();
} }
......
...@@ -28,7 +28,7 @@ public class TestCluster extends TestBase { ...@@ -28,7 +28,7 @@ public class TestCluster extends TestBase {
* *
* @param a ignored * @param a ignored
*/ */
public static void main(String[] a) throws Exception { public static void main(String... a) throws Exception {
TestBase.createCaller().init().test(); TestBase.createCaller().init().test();
} }
...@@ -59,13 +59,11 @@ public class TestCluster extends TestBase { ...@@ -59,13 +59,11 @@ public class TestCluster extends TestBase {
check(conn, len); check(conn, len);
conn.close(); conn.close();
CreateCluster.main(new String[] { "-urlSource", urlNode1, "-urlTarget", CreateCluster.main("-urlSource", urlNode1, "-urlTarget",
urlNode2, "-user", user, "-password", password, "-serverList", urlNode2, "-user", user, "-password", password, "-serverList",
"localhost:9191,localhost:9192" }); "localhost:9191,localhost:9192");
Server n1 = org.h2.tools.Server.createTcpServer( Server n1 = org.h2.tools.Server.createTcpServer("-tcpPort", "9191", "-baseDir", baseDir + "/node1").start();
new String[] { "-tcpPort", "9191", "-baseDir", baseDir + "/node1" }).start(); Server n2 = org.h2.tools.Server.createTcpServer("-tcpPort", "9192", "-baseDir", baseDir + "/node2").start();
Server n2 = org.h2.tools.Server.createTcpServer(
new String[] { "-tcpPort", "9192", "-baseDir", baseDir + "/node2" }).start();
try { try {
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191/test", user, password); conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191/test", user, password);
...@@ -99,14 +97,12 @@ public class TestCluster extends TestBase { ...@@ -99,14 +97,12 @@ public class TestCluster extends TestBase {
n1.stop(); n1.stop();
// re-create the cluster // re-create the cluster
DeleteDbFiles.main(new String[] { "-dir", baseDir + "/node2", "-quiet" }); DeleteDbFiles.main("-dir", baseDir + "/node2", "-quiet");
CreateCluster.main(new String[] { "-urlSource", urlNode1, "-urlTarget", CreateCluster.main("-urlSource", urlNode1, "-urlTarget",
urlNode2, "-user", user, "-password", password, "-serverList", urlNode2, "-user", user, "-password", password, "-serverList",
"localhost:9191,localhost:9192" }); "localhost:9191,localhost:9192");
n1 = org.h2.tools.Server.createTcpServer( n1 = org.h2.tools.Server.createTcpServer("-tcpPort", "9191", "-baseDir", baseDir + "/node1").start();
new String[] { "-tcpPort", "9191", "-baseDir", baseDir + "/node1" }).start(); n2 = org.h2.tools.Server.createTcpServer("-tcpPort", "9192", "-baseDir", baseDir + "/node2").start();
n2 = org.h2.tools.Server.createTcpServer(
new String[] { "-tcpPort", "9192", "-baseDir", baseDir + "/node2" }).start();
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191,localhost:9192/test", user, password); conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191,localhost:9192/test", user, password);
stat = conn.createStatement(); stat = conn.createStatement();
...@@ -118,15 +114,13 @@ public class TestCluster extends TestBase { ...@@ -118,15 +114,13 @@ public class TestCluster extends TestBase {
conn.close(); conn.close();
n2.stop(); n2.stop();
n1 = org.h2.tools.Server.createTcpServer(new String[] { "-tcpPort", "9191", "-baseDir", baseDir + "/node1" }) n1 = org.h2.tools.Server.createTcpServer("-tcpPort", "9191", "-baseDir", baseDir + "/node1").start();
.start();
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191/test;CLUSTER=''", user, password); conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191/test;CLUSTER=''", user, password);
check(conn, len); check(conn, len);
conn.close(); conn.close();
n1.stop(); n1.stop();
n2 = org.h2.tools.Server.createTcpServer(new String[] { "-tcpPort", "9192", "-baseDir", baseDir + "/node2" }) n2 = org.h2.tools.Server.createTcpServer("-tcpPort", "9192", "-baseDir", baseDir + "/node2").start();
.start();
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test;CLUSTER=''", user, password); conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test;CLUSTER=''", user, password);
check(conn, len); check(conn, len);
conn.createStatement().execute("SELECT * FROM A"); conn.createStatement().execute("SELECT * FROM A");
...@@ -136,8 +130,8 @@ public class TestCluster extends TestBase { ...@@ -136,8 +130,8 @@ public class TestCluster extends TestBase {
} }
private void deleteFiles() throws SQLException { private void deleteFiles() throws SQLException {
DeleteDbFiles.main(new String[] { "-dir", baseDir + "/node1", "-quiet" }); DeleteDbFiles.main("-dir", baseDir + "/node1", "-quiet");
DeleteDbFiles.main(new String[] { "-dir", baseDir + "/node2", "-quiet" }); DeleteDbFiles.main("-dir", baseDir + "/node2", "-quiet");
} }
private void check(Connection conn, int len) throws SQLException { private void check(Connection conn, int len) throws SQLException {
......
...@@ -26,7 +26,7 @@ public class TestCompatibility extends TestBase { ...@@ -26,7 +26,7 @@ public class TestCompatibility extends TestBase {
* *
* @param a ignored * @param a ignored
*/ */
public static void main(String[] a) throws Exception { public static void main(String... a) throws Exception {
TestBase.createCaller().init().test(); TestBase.createCaller().init().test();
} }
......
...@@ -39,7 +39,7 @@ public class TestCsv extends TestBase { ...@@ -39,7 +39,7 @@ public class TestCsv extends TestBase {
* *
* @param a ignored * @param a ignored
*/ */
public static void main(String[] a) throws Exception { public static void main(String... a) throws Exception {
TestBase.createCaller().init().test(); TestBase.createCaller().init().test();
} }
......
...@@ -38,7 +38,7 @@ public class TestDeadlock extends TestBase { ...@@ -38,7 +38,7 @@ public class TestDeadlock extends TestBase {
* *
* @param a ignored * @param a ignored
*/ */
public static void main(String[] a) throws Exception { public static void main(String... a) throws Exception {
TestBase.createCaller().init().test(); TestBase.createCaller().init().test();
} }
......
...@@ -23,7 +23,7 @@ public class TestEncryptedDb extends TestBase { ...@@ -23,7 +23,7 @@ public class TestEncryptedDb extends TestBase {
* *
* @param a ignored * @param a ignored
*/ */
public static void main(String[] a) throws Exception { public static void main(String... a) throws Exception {
TestBase.createCaller().init().test(); TestBase.createCaller().init().test();
} }
......
...@@ -22,7 +22,7 @@ public class TestExclusive extends TestBase { ...@@ -22,7 +22,7 @@ public class TestExclusive extends TestBase {
* *
* @param a ignored * @param a ignored
*/ */
public static void main(String[] a) throws Exception { public static void main(String... a) throws Exception {
TestBase.createCaller().init().test(); TestBase.createCaller().init().test();
} }
......
...@@ -27,7 +27,7 @@ public class TestFullText extends TestBase { ...@@ -27,7 +27,7 @@ public class TestFullText extends TestBase {
* *
* @param a ignored * @param a ignored
*/ */
public static void main(String[] a) throws Exception { public static void main(String... a) throws Exception {
TestBase.createCaller().init().test(); TestBase.createCaller().init().test();
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论