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

Use varargs.

上级 7ad501b1
......@@ -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:
</p>
<pre>
Server server = Server.createPgServer(new String[]{"-baseDir", "~"});
Server server = Server.createPgServer("-baseDir", "~");
server.start();
...
server.stop();
......
......@@ -18,7 +18,8 @@ Change Log
<h1>Change Log</h1>
<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 110: Multi-version concurrency / wrong exception is thrown.
</li><li>Parser: sequenceName.NEXTVAL and CURRVAL did not respect the schema search path.
......
......@@ -1544,8 +1544,8 @@ public static ResultSet simpleResultSet() throws SQLException {
SimpleResultSet rs = new SimpleResultSet();
rs.addColumn("ID", Types.INTEGER, 10, 0);
rs.addColumn("NAME", Types.VARCHAR, 255, 0);
rs.addRow(new Object[] { new Integer(0), "Hello" });
rs.addRow(new Object[] { new Integer(1), "World" });
rs.addRow(0, "Hello");
rs.addRow(1, "World");
return rs;
}
......@@ -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 y = 0; y &lt; s; y++) {
rs.addRow(new Object[] {
new Integer(x), new Integer(y) });
rs.addRow(x, y);
}
}
return rs;
......
......@@ -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>.
</p>
<h2>Version 1.2</h2>
<ul><li>Enable system property h2.optimizeInList by default
</li></ul>
<h2>Priority 1</h2>
<ul>
<li>Bugfixes
......@@ -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>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>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>Full outer joins
</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>.
</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>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>Deferred integrity checking (DEFERRABLE INITIALLY DEFERRED)
</li><li>Groovy Stored Procedures (http://groovy.codehaus.org/Groovy+SQL)
......
......@@ -527,8 +527,8 @@ public class TestCsv {
SimpleResultSet rs = new SimpleResultSet();
rs.addColumn("NAME", Types.VARCHAR, 255, 0);
rs.addColumn("EMAIL", Types.VARCHAR, 255, 0);
rs.addRow(new String[] { "Bob Meier", "bob.meier@abcde.abc" });
rs.addRow(new String[] { "John Jones", "john.jones@abcde.abc" });
rs.addRow("Bob Meier", "bob.meier@abcde.abc");
rs.addRow("John Jones", "john.jones@abcde.abc");
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 {
if (e.getErrorCode() == ErrorCode.CONCURRENT_UPDATE_1) {
long now = System.currentTimeMillis();
if (now - start > session.getLockTimeout()) {
throw Message.getSQLException(ErrorCode.LOCK_TIMEOUT_1, new String[]{""}, e);
throw Message.getSQLException(ErrorCode.LOCK_TIMEOUT_1, e, "");
}
try {
if (sync == database) {
......
......@@ -2779,7 +2779,7 @@ public class Parser {
try {
bd = new BigDecimal(sub);
} 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);
currentValue = ValueDecimal.get(bd);
......
......@@ -202,8 +202,8 @@ public class AlterTableAlterColumn extends SchemaCommand {
private void checkNoViews() throws SQLException {
for (DbObject child : table.getChildren()) {
if (child.getType() == DbObject.TABLE_OR_VIEW) {
throw Message.getSQLException(ErrorCode.OPERATION_NOT_SUPPORTED_WITH_VIEWS_2, new String[] {
table.getName(), child.getName() });
throw Message.getSQLException(ErrorCode.OPERATION_NOT_SUPPORTED_WITH_VIEWS_2,
table.getName(), child.getName());
}
}
}
......
......@@ -71,7 +71,7 @@ public class AlterSequence extends SchemaCommand {
if (increment != null) {
long incrementValue = increment.optimize(session).getValue(session).getLong();
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);
}
......
......@@ -72,7 +72,7 @@ public class CompressDeflate implements Compressor {
try {
decompresser.inflate(out, outPos, outLen);
} catch (DataFormatException e) {
throw Message.getSQLException(ErrorCode.COMPRESSION_ERROR, null, e);
throw Message.getSQLException(ErrorCode.COMPRESSION_ERROR, e);
}
decompresser.end();
}
......
......@@ -1596,8 +1596,7 @@ public class ErrorCode {
* </pre>
* Or, when starting the server from an application, use:
* <pre>
* Server server = Server.createTcpServer(new String[] {
* "-tcpAllowOthers" });
* Server server = Server.createTcpServer("-tcpAllowOthers");
* server.start();
* </pre>
*/
......
......@@ -525,7 +525,7 @@ public class ConnectionInfo implements Cloneable {
*/
SQLException getFormatException() {
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 {
}
private void startServer(String key) throws SQLException {
server = Server.createTcpServer(new String[]{
server = Server.createTcpServer(
"-tcpPort", "0",
"-tcpAllowOthers", "true",
"-key", key, databaseName});
"-key", key, databaseName);
server.start();
String address = NetUtils.getLocalAddress() + ":" + server.getPort();
lock.setProperty("server", address);
......@@ -1711,7 +1711,7 @@ public class Database implements DataHandler {
}
if (invalid != null) {
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);
}
......@@ -1848,8 +1848,7 @@ public class Database implements DataHandler {
}
eventListener.init(url);
} catch (Throwable e) {
throw Message.getSQLException(ErrorCode.ERROR_SETTING_DATABASE_EVENT_LISTENER_2, new String[] {
className, e.toString() }, e);
throw Message.getSQLException(ErrorCode.ERROR_SETTING_DATABASE_EVENT_LISTENER_2, e, className, e.toString());
}
}
}
......
......@@ -75,11 +75,9 @@ public class FunctionAlias extends DbObjectBase {
JavaMethod javaMethod = new JavaMethod(m, i);
for (JavaMethod old : list) {
if (old.getParameterCount() == javaMethod.getParameterCount()) {
throw Message.getSQLException(ErrorCode.METHODS_MUST_HAVE_DIFFERENT_PARAMETER_COUNTS_2,
new String[] {
old.toString(),
javaMethod.toString()
}
throw Message.getSQLException(
ErrorCode.METHODS_MUST_HAVE_DIFFERENT_PARAMETER_COUNTS_2,
old.toString(), javaMethod.toString()
);
}
}
......
......@@ -226,7 +226,7 @@ public class User extends RightOwner {
public void checkOwnsNoSchemas() throws SQLException {
for (Schema s : database.getAllSchemas()) {
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 {
varArgs.add(param);
} else {
if (index >= args.length) {
throw Message.getSQLException(ErrorCode.INVALID_PARAMETER_COUNT_2, new String[] { info.name,
"" + args.length });
throw Message.getSQLException(ErrorCode.INVALID_PARAMETER_COUNT_2, info.name,
"" + args.length);
}
args[index] = param;
}
......@@ -988,7 +988,7 @@ public class Function extends Expression implements FunctionCall {
try {
result = ValueString.get(v0.getString().replaceAll(regexp, v2.getString()));
} 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;
}
......@@ -1216,7 +1216,7 @@ public class Function extends Expression implements FunctionCall {
private static int getDatePart(String part) throws SQLException {
Integer p = DATE_PART.get(StringUtils.toUpperEnglish(part));
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();
}
......@@ -1553,8 +1553,7 @@ public class Function extends Expression implements FunctionCall {
}
boolean ok = (len >= min) && (len <= max);
if (!ok) {
throw Message.getSQLException(ErrorCode.INVALID_PARAMETER_COUNT_2, new String[] { info.name,
min + ".." + max });
throw Message.getSQLException(ErrorCode.INVALID_PARAMETER_COUNT_2, info.name, min + ".." + max);
}
}
......@@ -1575,7 +1574,7 @@ public class Function extends Expression implements FunctionCall {
int len = args.length;
if (len > 0 && args[len - 1] == null) {
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 {
protected void checkParameterCount(int len) throws SQLException {
if (len < 1) {
throw Message.getSQLException(ErrorCode.INVALID_PARAMETER_COUNT_2, new String[] { getName(),
">0" });
throw Message.getSQLException(ErrorCode.INVALID_PARAMETER_COUNT_2, getName(), ">0");
}
}
......
......@@ -551,18 +551,16 @@ public class FullText {
IndexInfo index = setting.getIndexInfo(indexId);
if (data) {
Object[][] columnData = parseKey(conn, key);
Object[] row = new Object[] {
index.schema,
index.table,
columnData[0],
columnData[1]
};
result.addRow(row);
result.addRow(
index.schema,
index.table,
columnData[0],
columnData[1]);
} else {
String query = StringUtils.quoteIdentifier(index.schema) +
"." + StringUtils.quoteIdentifier(index.table) +
" WHERE " + key;
result.addRow(new String[] { query });
result.addRow(query);
}
rowCount++;
if (limit > 0 && rowCount >= limit) {
......
......@@ -357,15 +357,13 @@ public class FullTextLucene extends FullText {
String tableName = expr.getColumnName();
q = q.substring(idx + " WHERE ".length());
Object[][] columnData = parseKey(conn, q);
Object[] row = new Object[] {
schemaName,
tableName,
columnData[0],
columnData[1]
};
result.addRow(row);
result.addRow(
schemaName,
tableName,
columnData[0],
columnData[1]);
} else {
result.addRow(new Object[] { q });
result.addRow(q);
}
}
// TODO keep it open if possible
......
......@@ -59,6 +59,7 @@ public class IndexCursor implements Cursor {
/**
* Re-evaluate the start and end values of the index search for rows.
*
* @param session the session
* @param indexConditions the index conditions
*/
public void find(Session session, ObjectArray<IndexCondition> indexConditions) throws SQLException {
......
......@@ -242,10 +242,7 @@ public class JdbcArray extends TraceObject implements Array {
// TODO array result set: there are multiple data types possible
rs.addColumn("VALUE", Types.NULL, 0, 0);
for (int i = 0; i < array.length; i++) {
Object[] row = new Object[2];
row[0] = Long.valueOf(offset + i + 1);
row[1] = array[i];
rs.addRow(row);
rs.addRow(Long.valueOf(offset + i + 1), array[i]);
}
return rs;
}
......
......@@ -45,7 +45,7 @@ import org.h2.message.Message;
* import java.sql.*;
* import org.h2.jdbcx.JdbcConnectionPool;
* public class Test {
* public static void main(String[] args) throws Exception {
* public static void main(String... args) throws Exception {
* JdbcConnectionPool cp = JdbcConnectionPool.create(
* "jdbc:h2:~/test", "sa", "sa");
* for (String sql : args) {
......
......@@ -75,7 +75,7 @@ public class Message {
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;
if (MESSAGES != null) {
// Tomcat sets final static fields to null sometimes
......@@ -95,11 +95,11 @@ public class Message {
* Gets the SQL exception object for a specific error code.
*
* @param errorCode the error code
* @param params the list of parameters of the message
* @param cause the cause of the exception
* @param params the list of parameters of the message
* @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 message = translate(sqlstate, params);
return new JdbcSQLException(message, null, sqlstate, errorCode, cause, null);
......@@ -112,8 +112,8 @@ public class Message {
* @param params the list of parameters of the message
* @return the SQLException object
*/
public static JdbcSQLException getSQLException(int errorCode, String[] params) {
return getSQLException(errorCode, params, null);
public static JdbcSQLException getSQLException(int errorCode, String... params) {
return getSQLException(errorCode, null, params);
}
/**
......@@ -138,7 +138,7 @@ public class Message {
*/
public static SQLException getSyntaxError(String sql, int index, String expected) {
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 {
* @return the SQLException object
*/
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 {
if (e instanceof SQLException) {
return (SQLException) e;
} 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) {
InvocationTargetException te = (InvocationTargetException) e;
Throwable t = te.getTargetException();
if (t instanceof SQLException) {
return (SQLException) t;
}
return getSQLException(ErrorCode.EXCEPTION_IN_FUNCTION, null, e);
return getSQLException(ErrorCode.EXCEPTION_IN_FUNCTION, e);
} 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 {
if (t != null && t instanceof SQLException) {
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 {
try {
writer = (TraceWriter) ClassUtils.loadSystemClass(adapterClass).newInstance();
} 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);
return;
}
......@@ -284,8 +284,7 @@ public class TraceSystem implements TraceWriter {
return;
}
writingErrorLogged = true;
SQLException se = Message.getSQLException(ErrorCode.TRACE_FILE_ERROR_2, new String[] { fileName, e.toString() },
e);
SQLException se = Message.getSQLException(ErrorCode.TRACE_FILE_ERROR_2, e, fileName, e.toString());
// print this error only once
fileName = null;
System.out.println(se);
......
......@@ -52,7 +52,7 @@ public class Sequence extends SchemaObjectBase {
public void setIncrement(long inc) throws SQLException {
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;
}
......
......@@ -66,8 +66,8 @@ public class TriggerObject extends SchemaObjectBase {
} catch (Throwable e) {
// try again later
triggerCallback = null;
throw Message.getSQLException(ErrorCode.ERROR_CREATING_TRIGGER_OBJECT_3, new String[] { getName(),
triggerClassName, e.toString() }, e);
throw Message.getSQLException(ErrorCode.ERROR_CREATING_TRIGGER_OBJECT_3, e, getName(),
triggerClassName, e.toString());
}
}
......@@ -108,8 +108,8 @@ public class TriggerObject extends SchemaObjectBase {
try {
triggerCallback.fire(c2, null, null);
} catch (Throwable e) {
throw Message.getSQLException(ErrorCode.ERROR_EXECUTING_TRIGGER_3, new String[] { getName(),
triggerClassName, e.toString() }, e);
throw Message.getSQLException(ErrorCode.ERROR_EXECUTING_TRIGGER_3, e, getName(),
triggerClassName, e.toString());
} finally {
session.setCommitOrRollbackDisabled(old);
}
......
......@@ -21,7 +21,7 @@ public interface Service {
*
* @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
......
......@@ -146,7 +146,7 @@ public class TcpServer implements Service {
}
}
public void init(String[] args) {
public void init(String... args) {
port = DEFAULT_PORT;
for (int i = 0; args != null && i < args.length; i++) {
String a = args[i];
......
......@@ -74,8 +74,9 @@ public class TcpServerThread implements Runnable {
// version 6 and newer: read max version (currently not used)
transfer.readInt();
} else if (clientVersion != Constants.TCP_PROTOCOL_VERSION_5) {
throw Message.getSQLException(ErrorCode.DRIVER_VERSION_ERROR_2, new String[] { "" + clientVersion,
"" + Constants.TCP_PROTOCOL_VERSION_5 });
throw Message.getSQLException(ErrorCode.DRIVER_VERSION_ERROR_2,
"" + clientVersion,
"" + Constants.TCP_PROTOCOL_VERSION_5);
}
String db = transfer.readString();
String originalURL = transfer.readString();
......
......@@ -72,7 +72,7 @@ public class PgServer implements Service {
private boolean allowOthers;
private boolean ifExists;
public void init(String[] args) {
public void init(String... args) {
port = DEFAULT_PORT;
for (int i = 0; args != null && i < args.length; i++) {
String a = args[i];
......
......@@ -216,7 +216,7 @@ public class WebServer implements Service {
return startDateTime;
}
public void init(String[] args) {
public void init(String... args) {
// TODO web: support using a different properties file
Properties prop = loadProperties();
port = SortedProperties.getIntProperty(prop, "webPort", Constants.DEFAULT_HTTP_PORT);
......
......@@ -449,7 +449,7 @@ public class FileLock {
}
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) {
......
......@@ -50,11 +50,11 @@ public class FileObjectDiskMapped implements FileObject {
if (SysProperties.NIO_CLEANER_HACK) {
try {
useSystemGc = false;
Method cleanerMethod = mapped.getClass().getMethod("cleaner", new Class[0]);
Method cleanerMethod = mapped.getClass().getMethod("cleaner");
cleanerMethod.setAccessible(true);
Object cleaner = cleanerMethod.invoke(mapped, new Object[0]);
Method clearMethod = cleaner.getClass().getMethod("clear", new Class[0]);
clearMethod.invoke(cleaner, new Object[0]);
Object cleaner = cleanerMethod.invoke(mapped);
Method clearMethod = cleaner.getClass().getMethod("clear");
clearMethod.invoke(cleaner);
} catch (Throwable e) {
useSystemGc = true;
}
......
......@@ -71,8 +71,9 @@ public class FileSystemDisk extends FileSystem {
Message.throwInternalError("rename file old=new");
}
if (!oldFile.exists()) {
throw Message.getSQLException(ErrorCode.FILE_RENAME_FAILED_2, new String[] { oldName + " (not found)",
newName });
throw Message.getSQLException(ErrorCode.FILE_RENAME_FAILED_2,
oldName + " (not found)",
newName);
}
if (newFile.exists()) {
throw Message.getSQLException(ErrorCode.FILE_RENAME_FAILED_2,
......
......@@ -299,7 +299,7 @@ public class Column {
s = s.substring(0, 128) + "...";
}
throw Message.getSQLException(ErrorCode.VALUE_TOO_LONG_2,
new String[] { getCreateSQL(), s + " (" + value.getPrecision() + ")" });
getCreateSQL(), s + " (" + value.getPrecision() + ")");
}
}
updateSequenceIfRequired(session, value);
......
......@@ -74,7 +74,7 @@ public class LinkSchema {
append(StringUtils.quoteStringSQL(table)).
append(')');
stat.execute(buff.toString());
result.addRow(new String[] { table });
result.addRow(table);
}
} finally {
JdbcUtils.closeSilently(rs);
......
......@@ -169,8 +169,8 @@ public class TableLink extends Table {
}
rs.close();
} catch (SQLException e) {
throw Message.getSQLException(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, new String[] { originalTable + "("
+ e.toString() + ")" }, e);
throw Message.getSQLException(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, e,
originalTable + "(" + e.toString() + ")");
} finally {
JdbcUtils.closeSilently(stat);
}
......@@ -391,7 +391,7 @@ public class TableLink extends Table {
* @return the wrapped SQL exception
*/
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() {
......
......@@ -256,7 +256,7 @@ public class TableView extends Table {
public Index getScanIndex(Session session) throws SQLException {
if (createException != null) {
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);
return item.getIndex();
......
......@@ -46,11 +46,11 @@ public class Backup extends Tool {
*
* @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);
}
public void run(String[] args) throws SQLException {
public void run(String... args) throws SQLException {
String zipFileName = "backup.zip";
String dir = ".";
String db = null;
......
......@@ -51,11 +51,11 @@ public class ChangeFileEncryption extends Tool {
*
* @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);
}
public void run(String[] args) throws SQLException {
public void run(String... args) throws SQLException {
String dir = ".";
String cipher = null;
char[] decryptPassword = null;
......
......@@ -117,7 +117,7 @@ public class CompressTool {
compress.expand(in, start, in.length - start, buff, 0, len);
return buff;
} 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 {
int start = 1 + getLength(len);
compress.expand(in, start, in.length - start, out, outPos, len);
} catch (Exception e) {
throw Message.getSQLException(ErrorCode.COMPRESSION_ERROR, null, e);
throw Message.getSQLException(ErrorCode.COMPRESSION_ERROR, e);
}
}
......
......@@ -87,7 +87,7 @@ ShutdownHandler {
*
* @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);
}
......@@ -98,7 +98,7 @@ ShutdownHandler {
*
* @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");
boolean tcpStart = false, pgStart = false, webStart = false, toolStart = false;
boolean browserStart = false;
......@@ -256,8 +256,8 @@ ShutdownHandler {
try {
// SystemTray.isSupported();
Boolean supported = (Boolean) Class.forName("java.awt.SystemTray").
getMethod("isSupported", new Class[0]).
invoke(null, new Object[0]);
getMethod("isSupported").
invoke(null);
if (!supported.booleanValue()) {
return false;
......@@ -282,30 +282,30 @@ ShutdownHandler {
// SystemTray tray = SystemTray.getSystemTray();
Object tray = Class.forName("java.awt.SystemTray").
getMethod("getSystemTray", new Class[0]).
invoke(null, new Object[0]);
getMethod("getSystemTray").
invoke(null);
// Dimension d = tray.getTrayIconSize();
Dimension d = (Dimension) Class.forName("java.awt.SystemTray").
getMethod("getTrayIconSize", new Class[0]).
invoke(tray, new Object[0]);
getMethod("getTrayIconSize").
invoke(tray);
Image icon = (d.width >= 24 && d.height >= 24) ? icon24 : icon16;
// TrayIcon icon = new TrayIcon(image, "H2 Database Engine", menuConsole);
Object trayIcon = Class.forName("java.awt.TrayIcon").
getConstructor(new Class[] { Image.class, String.class, PopupMenu.class }).
newInstance(new Object[] { icon, "H2 Database Engine", menuConsole });
getConstructor(Image.class, String.class, PopupMenu.class).
newInstance(icon, "H2 Database Engine", menuConsole);
// trayIcon.addMouseListener(this);
trayIcon.getClass().
getMethod("addMouseListener", new Class[]{MouseListener.class}).
invoke(trayIcon, new Object[]{this});
getMethod("addMouseListener", MouseListener.class).
invoke(trayIcon, this);
// tray.add(icon);
tray.getClass().
getMethod("add", new Class[] { Class.forName("java.awt.TrayIcon") }).
invoke(tray, new Object[] { trayIcon });
getMethod("add", Class.forName("java.awt.TrayIcon")).
invoke(tray, trayIcon);
return true;
} catch (Exception e) {
......
......@@ -72,11 +72,11 @@ public class ConvertTraceFile extends Tool {
*
* @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);
}
public void run(String[] args) throws SQLException {
public void run(String... args) throws SQLException {
String traceFile = "test.trace.db";
String javaClass = "Test";
String script = "test.sql";
......@@ -123,7 +123,7 @@ public class ConvertTraceFile extends Tool {
cn = cn.substring(idx + 1);
}
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\");");
while (true) {
String line = reader.readLine();
......
......@@ -43,11 +43,11 @@ public class CreateCluster extends Tool {
*
* @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);
}
public void run(String[] args) throws SQLException {
public void run(String... args) throws SQLException {
String urlSource = null;
String urlTarget = null;
String user = "sa";
......
......@@ -39,11 +39,11 @@ public class DeleteDbFiles extends Tool {
*
* @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);
}
public void run(String[] args) throws SQLException {
public void run(String... args) throws SQLException {
String dir = ".";
String db = null;
boolean quiet = false;
......
......@@ -100,7 +100,7 @@ public class Recover extends Tool implements DataHandler {
*
* @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);
}
......@@ -115,7 +115,7 @@ public class Recover extends Tool implements DataHandler {
*
* @param args the command line arguments
*/
public void run(String[] args) throws SQLException {
public void run(String... args) throws SQLException {
String dir = ".";
String db = null;
for (int i = 0; args != null && i < args.length; i++) {
......
......@@ -44,11 +44,11 @@ public class Restore extends Tool {
*
* @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);
}
public void run(String[] args) throws SQLException {
public void run(String... args) throws SQLException {
String zipFileName = "backup.zip";
String dir = ".";
String db = null;
......
......@@ -62,7 +62,7 @@ public class RunScript extends Tool {
*
* @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);
}
......@@ -84,7 +84,7 @@ public class RunScript extends Tool {
*
* @param args the command line arguments
*/
public void run(String[] args) throws SQLException {
public void run(String... args) throws SQLException {
String url = null;
String user = "sa";
String password = "";
......
......@@ -48,11 +48,11 @@ public class Script extends Tool {
*
* @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);
}
public void run(String[] args) throws SQLException {
public void run(String... args) throws SQLException {
String url = null;
String user = "sa";
String password = "";
......
......@@ -41,7 +41,7 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
* @param service the service
* @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;
try {
service.init(args);
......@@ -98,11 +98,11 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
*
* @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);
}
public void run(String[] args) throws SQLException {
public void run(String... args) throws SQLException {
boolean tcpStart = false, pgStart = false, webStart = false;
boolean browserStart = false;
boolean tcpShutdown = false, tcpShutdownForce = false;
......@@ -298,7 +298,7 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
* @param args the argument list
* @return the server
*/
public static Server createWebServer(String[] args) throws SQLException {
public static Server createWebServer(String... args) throws SQLException {
WebServer service = new WebServer();
Server server = new Server(service, args);
service.setShutdownHandler(server);
......@@ -316,7 +316,7 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
* @param args the argument list
* @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);
}
......@@ -325,14 +325,13 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
* Example:
* <pre>
* Server server =
* Server.createPgServer(new String[]{
* "-pgAllowOthers"}).start();
* Server.createPgServer("-pgAllowOthers").start();
* </pre>
*
* @param args the argument list
* @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);
}
......@@ -356,7 +355,7 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
if (isRunning(true)) {
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) {
......
......@@ -65,7 +65,7 @@ public class Shell extends Tool {
*
* @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);
}
......@@ -101,7 +101,7 @@ public class Shell extends Tool {
*
* @param args the command line settings
*/
public void run(String[] args) throws SQLException {
public void run(String... args) throws SQLException {
String url = null;
String user = "";
String password = "";
......@@ -348,11 +348,11 @@ public class Shell extends Tool {
private String readPassword() throws IOException {
try {
Method getConsole = System.class.getMethod("console", new Class[0]);
Object console = getConsole.invoke(null, (Object[]) null);
Method readPassword = console.getClass().getMethod("readPassword", new Class[0]);
Method getConsole = System.class.getMethod("console");
Object console = getConsole.invoke(null);
Method readPassword = console.getClass().getMethod("readPassword");
print("Password ");
char[] password = (char[]) readPassword.invoke(console, (Object[]) null);
char[] password = (char[]) readPassword.invoke(console);
return password == null ? null : new String(password);
} catch (Exception e) {
// ignore, use the default solution
......
......@@ -47,8 +47,8 @@ import java.sql.SQLXML;
* SimpleResultSet rs = new SimpleResultSet();
* rs.addColumn(&quot;ID&quot;, Types.INTEGER, 10, 0);
* rs.addColumn(&quot;NAME&quot;, Types.VARCHAR, 255, 0);
* rs.addRow(new Object[] { new Integer(0), &quot;Hello&quot; });
* rs.addRow(new Object[] { new Integer(1), &quot;World&quot; });
* rs.addRow(0, &quot;Hello&quot; });
* rs.addRow(1, &quot;World&quot; });
* </pre>
*
*/
......@@ -249,7 +249,7 @@ public class SimpleResultSet implements ResultSet, ResultSetMetaData {
*
* @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) {
throw new SQLException("Cannot add a row when using RowSource", "21S02");
}
......
......@@ -80,9 +80,9 @@ public class ClassUtils {
try {
return Class.forName(className);
} 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) {
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 {
return false;
}
try {
Method isVarArgs = m.getClass().getMethod("isVarArgs", new Class[0]);
Boolean result = (Boolean) isVarArgs.invoke(m, new Object[0]);
Method isVarArgs = m.getClass().getMethod("isVarArgs");
Boolean result = (Boolean) isVarArgs.invoke(m);
return result.booleanValue();
} catch (Exception e) {
return false;
......
......@@ -251,7 +251,7 @@ public class DateTimeUtils {
int s1 = s.indexOf('-', 1);
int s2 = s.indexOf('-', s1 + 1);
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));
month = Integer.parseInt(s.substring(s1 + 1, s2));
......@@ -264,7 +264,7 @@ public class DateTimeUtils {
int s2 = s.indexOf(':', s1 + 1);
int s3 = s.indexOf('.', s2 + 1);
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")) {
......@@ -340,7 +340,7 @@ public class DateTimeUtils {
throw Message.throwInternalError("type:" + type);
}
} 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 {
return new ServerSocket(port, 0, bindAddress);
} catch (BindException be) {
throw Message.getSQLException(ErrorCode.EXCEPTION_OPENING_PORT_2,
new String[] { "" + port, be.toString() }, be);
be, "" + port, be.toString());
} catch (IOException e) {
throw Message.convertIOException(e, "port: " + port + " ssl: " + ssl);
}
......
......@@ -45,7 +45,7 @@ public class ObjectUtils {
os.writeObject(obj);
return out.toByteArray();
} 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 {
Object obj = is.readObject();
return obj;
} 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 {
// nanoseconds if available
try {
Method m = System.class.getMethod("nanoTime", new Class[0]);
Method m = System.class.getMethod("nanoTime");
if (m != null) {
Object o = m.invoke(null, (java.lang.Object[]) null);
Object o = m.invoke(null);
out.writeUTF(o.toString());
}
} catch (Exception e) {
......@@ -133,17 +133,13 @@ public class RandomUtils {
try {
// workaround for the Google App Engine: don't use InetAddress
Class< ? > inetAddressClass = Class.forName("java.net.InetAddress");
Object localHost = inetAddressClass.getMethod(
"getLocalHost", new Class[0]).invoke(null, new Object[0]);
String hostName = inetAddressClass.getMethod(
"getHostName", new Class[0]).invoke(localHost, new Object[0]).toString();
Object localHost = inetAddressClass.getMethod("getLocalHost").invoke(null);
String hostName = inetAddressClass.getMethod("getHostName").invoke(localHost).toString();
out.writeUTF(hostName);
Object[] list = (Object[]) inetAddressClass.getMethod(
"getAllByName", new Class[] { String.class })
.invoke(null, new Object[] { hostName });
Method getAddress = inetAddressClass.getMethod("getAddress", new Class[0]);
Object[] list = (Object[]) inetAddressClass.getMethod("getAllByName", String.class).invoke(null, hostName);
Method getAddress = inetAddressClass.getMethod("getAddress");
for (Object o : list) {
out.write((byte[]) getAddress.invoke(o, new Object[0]));
out.write((byte[]) getAddress.invoke(o));
}
} catch (Throwable e) {
// on some system, InetAddress is not supported
......
......@@ -49,16 +49,16 @@ public class StartBrowser {
Class< ? > desktopClass = Class.forName("java.awt.Desktop");
// Desktop.isDesktopSupported()
Boolean supported = (Boolean) desktopClass.
getMethod("isDesktopSupported", new Class[0]).
getMethod("isDesktopSupported").
invoke(null, new Object[0]);
URI uri = new URI(url);
if (supported.booleanValue()) {
// Desktop.getDesktop();
Object desktop = desktopClass.getMethod("getDesktop", new Class[0]).
Object desktop = desktopClass.getMethod("getDesktop").
invoke(null, new Object[0]);
// desktop.browse(uri);
desktopClass.getMethod("browse", new Class[] { URI.class }).
invoke(desktop, new Object[] { uri });
desktopClass.getMethod("browse", URI.class).
invoke(desktop, uri);
return;
}
} catch (Exception e) {
......
......@@ -530,7 +530,7 @@ public class StringUtils {
return dateFormat.parse(date);
}
} 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 {
}
return df;
} 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 {
*
* @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.
......
......@@ -772,7 +772,7 @@ public abstract class Value {
case RESULT_SET: {
SimpleResultSet rs = new SimpleResultSet();
rs.addColumn("X", Types.VARCHAR, s.length(), 0);
rs.addRow(new String[]{s});
rs.addRow(s);
return ValueResultSet.get(rs);
}
case UUID:
......@@ -781,7 +781,7 @@ public abstract class Value {
throw Message.throwInternalError("type=" + type);
}
} 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 {
if (value == null) {
throw new IllegalArgumentException();
} else if (!SysProperties.ALLOW_BIG_DECIMAL_EXTENSIONS && !value.getClass().equals(BigDecimal.class)) {
SQLException e = Message.getSQLException(ErrorCode.INVALID_CLASS_2, new String[] {
BigDecimal.class.getName(), value.getClass().getName() });
SQLException e = Message.getSQLException(ErrorCode.INVALID_CLASS_2,
BigDecimal.class.getName(), value.getClass().getName());
throw Message.convertToInternal(e);
}
this.value = value;
......
......@@ -28,7 +28,7 @@ public class Compact {
*
* @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);
Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection("jdbc:h2:data/test", "sa", "");
......
......@@ -28,7 +28,7 @@ public class CsvSample {
*
* @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.read();
}
......@@ -41,8 +41,8 @@ public class CsvSample {
rs.addColumn("NAME", Types.VARCHAR, 255, 0);
rs.addColumn("EMAIL", Types.VARCHAR, 255, 0);
rs.addColumn("PHONE", Types.VARCHAR, 255, 0);
rs.addRow(new String[] { "Bob Meier", "bob.meier@abcde.abc", "+41123456789" });
rs.addRow(new String[] { "John Jones", "john.jones@abcde.abc", "+41976543210" });
rs.addRow("Bob Meier", "bob.meier@abcde.abc", "+41123456789");
rs.addRow("John Jones", "john.jones@abcde.abc", "+41976543210");
Csv.getInstance().write("data/test.csv", rs, null);
}
......
......@@ -25,7 +25,7 @@ public class FileFunctions {
*
* @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");
Connection conn = DriverManager.getConnection("jdbc:h2:mem:", "sa", "");
Statement stat = conn.createStatement();
......
......@@ -28,7 +28,7 @@ public class Function {
*
* @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");
Connection conn = DriverManager.getConnection("jdbc:h2:mem:", "sa", "");
Statement stat = conn.createStatement();
......@@ -103,7 +103,7 @@ public class Function {
SimpleResultSet rs = new SimpleResultSet();
rs.addColumn("ID", Types.INTEGER, 10, 0);
rs.addColumn("NAME", Types.VARCHAR, 255, 0);
rs.addRow(new Object[] { new Integer(0), "Hello" });
rs.addRow(0, "Hello");
return rs;
}
......@@ -125,8 +125,7 @@ public class Function {
}
for (int s = size.intValue(), x = 0; x < s; x++) {
for (int y = 0; y < s; y++) {
rs.addRow(new Object[] {
new Integer(x), new Integer(y) });
rs.addRow(x, y);
}
}
return rs;
......
......@@ -30,7 +30,7 @@ public class FunctionMultiReturn {
*
* @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");
Connection conn = DriverManager.getConnection("jdbc:h2:mem:", "sa", "");
Statement stat = conn.createStatement();
......@@ -97,7 +97,7 @@ public class FunctionMultiReturn {
if (r != null && alpha != null) {
double x = r.doubleValue() * Math.cos(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;
}
......@@ -139,7 +139,7 @@ public class FunctionMultiReturn {
double alpha = rs.getDouble("A");
double x = r * Math.cos(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;
......
......@@ -27,7 +27,7 @@ public class InitDatabaseFromJar {
*
* @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().initDb();
}
......
......@@ -25,10 +25,10 @@ public class MixedMode {
*
* @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
Server server = Server.createTcpServer(new String[] { "-tcpPort", "9081" });
Server server = Server.createTcpServer("-tcpPort", "9081");
server.start();
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)");
......
......@@ -32,7 +32,7 @@ public class Newsfeed {
*
* @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];
Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection("jdbc:h2:mem:", "sa", "");
......
......@@ -32,7 +32,7 @@ public class SQLInjection {
*
* @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",
"jdbc:h2:test", "sa", "sa");
// new SQLInjection().run("org.postgresql.Driver",
......
......@@ -25,7 +25,7 @@ public class SecurePassword {
*
* @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");
String url = "jdbc:h2:data/simple";
......
......@@ -37,7 +37,7 @@ public class ShowProgress implements DatabaseEventListener {
*
* @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();
}
......
......@@ -18,7 +18,7 @@ public class ShutdownServer {
*
* @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);
}
}
......@@ -27,7 +27,7 @@ public class TriggerSample {
*
* @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");
Connection conn = DriverManager.getConnection("jdbc:h2:mem:", "sa", "");
Statement stat = conn.createStatement();
......
......@@ -278,14 +278,14 @@ java org.h2.test.TestAll timer
*
* @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();
run(args);
catcher.stop();
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);
long time = System.currentTimeMillis();
TestAll test = new TestAll();
......@@ -293,16 +293,12 @@ java org.h2.test.TestAll timer
System.setProperty("h2.maxMemoryRowsDistinct", "128");
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
......@@ -347,12 +343,12 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
System.setProperty(SysProperties.H2_PAGE_STORE, "true");
test.pageStore = true;
test.runTests();
TestPerformance.main(new String[]{ "-init", "-db", "1"});
TestPerformance.main("-init", "-db", "1");
System.setProperty(SysProperties.H2_PAGE_STORE, "false");
test.pageStore = false;
test.runTests();
TestPerformance.main(new String[]{ "-init", "-db", "1"});
TestPerformance.main("-init", "-db", "1");
}
System.out.println(TestBase.formatTime(System.currentTimeMillis() - time) + " total");
}
......
......@@ -90,11 +90,11 @@ class Database {
*/
void startServer() throws Exception {
if (url.startsWith("jdbc:h2:tcp:")) {
serverH2 = Server.createTcpServer(new String[0]).start();
serverH2 = Server.createTcpServer().start();
Thread.sleep(100);
} else if (url.startsWith("jdbc:derby://")) {
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 });
// serverDerby = new NetworkServerControl();
// serverDerby.start(null);
......@@ -102,7 +102,7 @@ class Database {
} else if (url.startsWith("jdbc:hsqldb:hsql:")) {
if (!serverHSQLDB) {
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",
"data/mydb;hsqldb.default_table_type=cached", "-dbname.0", "xdb" } });
// org.hsqldb.Server.main(new String[]{"-database.0", "mydb",
......@@ -122,7 +122,7 @@ class Database {
serverH2 = null;
}
if (serverDerby != null) {
Method m = serverDerby.getClass().getMethod("shutdown", new Class[] {});
Method m = serverDerby.getClass().getMethod("shutdown");
// cast for JDK 1.5
m.invoke(serverDerby, (Object[]) null);
// serverDerby.shutdown();
......
......@@ -45,7 +45,7 @@ public class TestPerformance {
*
* @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);
}
......@@ -68,7 +68,7 @@ public class TestPerformance {
}
}
private void test(String[] args) throws Exception {
private void test(String... args) throws Exception {
int dbId = -1;
boolean exit = false;
String out = "benchmark.html";
......
......@@ -57,11 +57,11 @@ public class Coverage {
*
* @param args the command line parameters
*/
public static void main(String[] args) {
public static void main(String... args) {
new Coverage().run(args);
}
private void run(String[] args) {
private void run(String... args) {
if (args.length == 0 || args[0].equals("-?")) {
printUsage();
return;
......
......@@ -22,7 +22,7 @@ public abstract class Task {
*
* @param args the command line arguments
*/
public static void main(String[] args) {
public static void main(String... args) {
SelfDestructor.startCountdown(60);
Task task;
try {
......@@ -49,7 +49,7 @@ public abstract class Task {
*
* @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.
......
......@@ -44,7 +44,7 @@ public class TaskProcess {
*
* @param args the arguments, or null
*/
public void start(String[] args) {
public void start(String... args) {
try {
String selfDestruct = SelfDestructor.getPropertyString(60);
ArrayList<String> list = new ArrayList<String>();
......
......@@ -27,7 +27,7 @@ public class TestAlter extends TestBase {
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
public static void main(String... a) throws Exception {
TestBase.createCaller().init().test();
}
......
......@@ -23,7 +23,7 @@ public class TestAutoRecompile extends TestBase {
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
public static void main(String... a) throws Exception {
TestBase.createCaller().init().test();
}
......
......@@ -25,7 +25,7 @@ public class TestBackup extends TestBase {
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
public static void main(String... a) throws Exception {
TestBase.createCaller().init().test();
}
......
......@@ -25,7 +25,7 @@ public class TestBigDb extends TestBase {
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
public static void main(String... a) throws Exception {
TestBase.createCaller().init().test();
}
......
......@@ -26,7 +26,7 @@ public class TestBigResult extends TestBase {
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
public static void main(String... a) throws Exception {
TestBase.createCaller().init().test();
}
......
......@@ -30,7 +30,7 @@ public class TestCases extends TestBase {
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
public static void main(String... a) throws Exception {
TestBase.createCaller().init().test();
}
......
......@@ -22,7 +22,7 @@ public class TestCheckpoint extends TestBase {
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
public static void main(String... a) throws Exception {
TestBase.createCaller().init().test();
}
......
......@@ -28,7 +28,7 @@ public class TestCluster extends TestBase {
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
public static void main(String... a) throws Exception {
TestBase.createCaller().init().test();
}
......@@ -59,13 +59,11 @@ public class TestCluster extends TestBase {
check(conn, len);
conn.close();
CreateCluster.main(new String[] { "-urlSource", urlNode1, "-urlTarget",
CreateCluster.main("-urlSource", urlNode1, "-urlTarget",
urlNode2, "-user", user, "-password", password, "-serverList",
"localhost:9191,localhost:9192" });
Server n1 = org.h2.tools.Server.createTcpServer(
new String[] { "-tcpPort", "9191", "-baseDir", baseDir + "/node1" }).start();
Server n2 = org.h2.tools.Server.createTcpServer(
new String[] { "-tcpPort", "9192", "-baseDir", baseDir + "/node2" }).start();
"localhost:9191,localhost:9192");
Server n1 = org.h2.tools.Server.createTcpServer("-tcpPort", "9191", "-baseDir", baseDir + "/node1").start();
Server n2 = org.h2.tools.Server.createTcpServer("-tcpPort", "9192", "-baseDir", baseDir + "/node2").start();
try {
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191/test", user, password);
......@@ -99,14 +97,12 @@ public class TestCluster extends TestBase {
n1.stop();
// re-create the cluster
DeleteDbFiles.main(new String[] { "-dir", baseDir + "/node2", "-quiet" });
CreateCluster.main(new String[] { "-urlSource", urlNode1, "-urlTarget",
DeleteDbFiles.main("-dir", baseDir + "/node2", "-quiet");
CreateCluster.main("-urlSource", urlNode1, "-urlTarget",
urlNode2, "-user", user, "-password", password, "-serverList",
"localhost:9191,localhost:9192" });
n1 = org.h2.tools.Server.createTcpServer(
new String[] { "-tcpPort", "9191", "-baseDir", baseDir + "/node1" }).start();
n2 = org.h2.tools.Server.createTcpServer(
new String[] { "-tcpPort", "9192", "-baseDir", baseDir + "/node2" }).start();
"localhost:9191,localhost:9192");
n1 = org.h2.tools.Server.createTcpServer("-tcpPort", "9191", "-baseDir", baseDir + "/node1").start();
n2 = org.h2.tools.Server.createTcpServer("-tcpPort", "9192", "-baseDir", baseDir + "/node2").start();
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191,localhost:9192/test", user, password);
stat = conn.createStatement();
......@@ -118,15 +114,13 @@ public class TestCluster extends TestBase {
conn.close();
n2.stop();
n1 = org.h2.tools.Server.createTcpServer(new String[] { "-tcpPort", "9191", "-baseDir", baseDir + "/node1" })
.start();
n1 = org.h2.tools.Server.createTcpServer("-tcpPort", "9191", "-baseDir", baseDir + "/node1").start();
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191/test;CLUSTER=''", user, password);
check(conn, len);
conn.close();
n1.stop();
n2 = org.h2.tools.Server.createTcpServer(new String[] { "-tcpPort", "9192", "-baseDir", baseDir + "/node2" })
.start();
n2 = org.h2.tools.Server.createTcpServer("-tcpPort", "9192", "-baseDir", baseDir + "/node2").start();
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test;CLUSTER=''", user, password);
check(conn, len);
conn.createStatement().execute("SELECT * FROM A");
......@@ -136,8 +130,8 @@ public class TestCluster extends TestBase {
}
private void deleteFiles() throws SQLException {
DeleteDbFiles.main(new String[] { "-dir", baseDir + "/node1", "-quiet" });
DeleteDbFiles.main(new String[] { "-dir", baseDir + "/node2", "-quiet" });
DeleteDbFiles.main("-dir", baseDir + "/node1", "-quiet");
DeleteDbFiles.main("-dir", baseDir + "/node2", "-quiet");
}
private void check(Connection conn, int len) throws SQLException {
......
......@@ -26,7 +26,7 @@ public class TestCompatibility extends TestBase {
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
public static void main(String... a) throws Exception {
TestBase.createCaller().init().test();
}
......
......@@ -39,7 +39,7 @@ public class TestCsv extends TestBase {
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
public static void main(String... a) throws Exception {
TestBase.createCaller().init().test();
}
......
......@@ -38,7 +38,7 @@ public class TestDeadlock extends TestBase {
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
public static void main(String... a) throws Exception {
TestBase.createCaller().init().test();
}
......
......@@ -23,7 +23,7 @@ public class TestEncryptedDb extends TestBase {
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
public static void main(String... a) throws Exception {
TestBase.createCaller().init().test();
}
......
......@@ -22,7 +22,7 @@ public class TestExclusive extends TestBase {
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
public static void main(String... a) throws Exception {
TestBase.createCaller().init().test();
}
......
......@@ -27,7 +27,7 @@ public class TestFullText extends TestBase {
*
* @param a ignored
*/
public static void main(String[] a) throws Exception {
public static void main(String... a) throws Exception {
TestBase.createCaller().init().test();
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论