提交 9caf303b authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 3169053d
#Fri Mar 14 15:37:20 CET 2008 #Tue Mar 18 08:37:19 CET 2008
benchmark.drivers.dir=C\:/data/java benchmark.drivers.dir=C\:/data/java
javac=javac javac=javac
jdk=1.4 jdk=1.4
......
...@@ -57,15 +57,20 @@ public class Backup { ...@@ -57,15 +57,20 @@ public class Backup {
String db = null; String db = null;
boolean quiet = false; boolean quiet = false;
for (int i = 0; args != null && i < args.length; i++) { for (int i = 0; args != null && i < args.length; i++) {
if (args[i].equals("-dir")) { String arg = args[i];
if (arg.equals("-dir")) {
dir = args[++i]; dir = args[++i];
} else if (args[i].equals("-db")) { } else if (arg.equals("-db")) {
db = args[++i]; db = args[++i];
} else if (args[i].equals("-quiet")) { } else if (arg.equals("-quiet")) {
quiet = true; quiet = true;
} else if (args[i].equals("-file")) { } else if (arg.equals("-file")) {
zipFileName = args[++i]; zipFileName = args[++i];
} else if (arg.equals("-help") || arg.equals("-?")) {
showUsage();
return;
} else { } else {
System.out.println("Unsupported option: " + arg);
showUsage(); showUsage();
return; return;
} }
......
...@@ -66,19 +66,24 @@ public class ChangePassword { ...@@ -66,19 +66,24 @@ public class ChangePassword {
String db = null; String db = null;
boolean quiet = false; boolean quiet = false;
for (int i = 0; args != null && i < args.length; i++) { for (int i = 0; args != null && i < args.length; i++) {
if (args[i].equals("-dir")) { String arg = args[i];
if (arg.equals("-dir")) {
dir = args[++i]; dir = args[++i];
} else if (args[i].equals("-cipher")) { } else if (arg.equals("-cipher")) {
cipher = args[++i]; cipher = args[++i];
} else if (args[i].equals("-db")) { } else if (arg.equals("-db")) {
db = args[++i]; db = args[++i];
} else if (args[i].equals("-decrypt")) { } else if (arg.equals("-decrypt")) {
decryptPassword = args[++i].toCharArray(); decryptPassword = args[++i].toCharArray();
} else if (args[i].equals("-encrypt")) { } else if (arg.equals("-encrypt")) {
encryptPassword = args[++i].toCharArray(); encryptPassword = args[++i].toCharArray();
} else if (args[i].equals("-quiet")) { } else if (arg.equals("-quiet")) {
quiet = true; quiet = true;
} else if (arg.equals("-help") || arg.equals("-?")) {
showUsage();
return;
} else { } else {
System.out.println("Unsupported option: " + arg);
showUsage(); showUsage();
return; return;
} }
......
...@@ -48,13 +48,18 @@ public class ConvertTraceFile { ...@@ -48,13 +48,18 @@ public class ConvertTraceFile {
String javaClass = "Test"; String javaClass = "Test";
String script = "test.sql"; String script = "test.sql";
for (int i = 0; args != null && i < args.length; i++) { for (int i = 0; args != null && i < args.length; i++) {
if (args[i].equals("-traceFile")) { String arg = args[i];
if (arg.equals("-traceFile")) {
traceFile = args[++i]; traceFile = args[++i];
} else if (args[i].equals("-javaClass")) { } else if (arg.equals("-javaClass")) {
javaClass = args[++i]; javaClass = args[++i];
} else if (args[i].equals("-script")) { } else if (arg.equals("-script")) {
script = args[++i]; script = args[++i];
} else if (arg.equals("-help") || arg.equals("-?")) {
showUsage();
return;
} else { } else {
System.out.println("Unsupported option: " + arg);
showUsage(); showUsage();
return; return;
} }
......
...@@ -51,17 +51,22 @@ public class CreateCluster { ...@@ -51,17 +51,22 @@ public class CreateCluster {
String password = ""; String password = "";
String serverlist = null; String serverlist = null;
for (int i = 0; args != null && i < args.length; i++) { for (int i = 0; args != null && i < args.length; i++) {
if (args[i].equals("-urlSource")) { String arg = args[i];
if (arg.equals("-urlSource")) {
urlSource = args[++i]; urlSource = args[++i];
} else if (args[i].equals("-urlTarget")) { } else if (arg.equals("-urlTarget")) {
urlTarget = args[++i]; urlTarget = args[++i];
} else if (args[i].equals("-user")) { } else if (arg.equals("-user")) {
user = args[++i]; user = args[++i];
} else if (args[i].equals("-password")) { } else if (arg.equals("-password")) {
password = args[++i]; password = args[++i];
} else if (args[i].equals("-serverlist")) { } else if (arg.equals("-serverlist")) {
serverlist = args[++i]; serverlist = args[++i];
} else if (arg.equals("-help") || arg.equals("-?")) {
showUsage();
return;
} else { } else {
System.out.println("Unsupported option: " + arg);
showUsage(); showUsage();
return; return;
} }
......
...@@ -46,13 +46,18 @@ public class DeleteDbFiles { ...@@ -46,13 +46,18 @@ public class DeleteDbFiles {
String db = null; String db = null;
boolean quiet = false; boolean quiet = false;
for (int i = 0; args != null && i < args.length; i++) { for (int i = 0; args != null && i < args.length; i++) {
if (args[i].equals("-dir")) { String arg = args[i];
if (arg.equals("-dir")) {
dir = args[++i]; dir = args[++i];
} else if (args[i].equals("-db")) { } else if (arg.equals("-db")) {
db = args[++i]; db = args[++i];
} else if (args[i].equals("-quiet")) { } else if (arg.equals("-quiet")) {
quiet = true; quiet = true;
} else if (arg.equals("-help") || arg.equals("-?")) {
showUsage();
return;
} else { } else {
System.out.println("Unsupported option: " + arg);
showUsage(); showUsage();
return; return;
} }
......
...@@ -98,16 +98,21 @@ public class Recover implements DataHandler { ...@@ -98,16 +98,21 @@ public class Recover implements DataHandler {
String db = null; String db = null;
boolean removePassword = false; boolean removePassword = false;
for (int i = 0; args != null && i < args.length; i++) { for (int i = 0; args != null && i < args.length; i++) {
if ("-dir".equals(args[i])) { String arg = args[i];
if ("-dir".equals(arg)) {
dir = args[++i]; dir = args[++i];
} else if ("-db".equals(args[i])) { } else if ("-db".equals(arg)) {
db = args[++i]; db = args[++i];
} else if ("-removePassword".equals(args[i])) { } else if ("-removePassword".equals(arg)) {
removePassword = true; removePassword = true;
log = true; log = true;
} else if ("-log".equals(args[i])) { } else if ("-log".equals(arg)) {
log = Boolean.valueOf(args[++i]).booleanValue(); log = Boolean.valueOf(args[++i]).booleanValue();
} else if (arg.equals("-help") || arg.equals("-?")) {
showUsage();
return;
} else { } else {
System.out.println("Unsupported option: " + arg);
showUsage(); showUsage();
return; return;
} }
......
...@@ -54,15 +54,20 @@ public class Restore { ...@@ -54,15 +54,20 @@ public class Restore {
String db = null; String db = null;
boolean quiet = false; boolean quiet = false;
for (int i = 0; args != null && i < args.length; i++) { for (int i = 0; args != null && i < args.length; i++) {
if (args[i].equals("-dir")) { String arg = args[i];
if (arg.equals("-dir")) {
dir = args[++i]; dir = args[++i];
} else if (args[i].equals("-file")) { } else if (arg.equals("-file")) {
zipFileName = args[++i]; zipFileName = args[++i];
} else if (args[i].equals("-db")) { } else if (arg.equals("-db")) {
db = args[++i]; db = args[++i];
} else if (args[i].equals("-quiet")) { } else if (arg.equals("-quiet")) {
quiet = true; quiet = true;
} else if (arg.equals("-help") || arg.equals("-?")) {
showUsage();
return;
} else { } else {
System.out.println("Unsupported option: " + arg);
showUsage(); showUsage();
return; return;
} }
......
...@@ -78,26 +78,27 @@ public class RunScript { ...@@ -78,26 +78,27 @@ public class RunScript {
boolean continueOnError = false; boolean continueOnError = false;
boolean showTime = false; boolean showTime = false;
for (int i = 0; args != null && i < args.length; i++) { for (int i = 0; args != null && i < args.length; i++) {
if (args[i].equals("-url")) { String arg = args[i];
if (arg.equals("-url")) {
url = args[++i]; url = args[++i];
} else if (args[i].equals("-user")) { } else if (arg.equals("-user")) {
user = args[++i]; user = args[++i];
} else if (args[i].equals("-password")) { } else if (arg.equals("-password")) {
password = args[++i]; password = args[++i];
} else if (args[i].equals("-continueOnError")) { } else if (arg.equals("-continueOnError")) {
continueOnError = true; continueOnError = true;
} else if (args[i].equals("-script")) { } else if (arg.equals("-script")) {
script = args[++i]; script = args[++i];
} else if (args[i].equals("-time")) { } else if (arg.equals("-time")) {
showTime = true; showTime = true;
} else if (args[i].equals("-driver")) { } else if (arg.equals("-driver")) {
String driver = args[++i]; String driver = args[++i];
try { try {
ClassUtils.loadUserClass(driver); ClassUtils.loadUserClass(driver);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
throw Message.convert(e); throw Message.convert(e);
} }
} else if (args[i].equals("-options")) { } else if (arg.equals("-options")) {
StringBuffer buff = new StringBuffer(); StringBuffer buff = new StringBuffer();
i++; i++;
for (; i < args.length; i++) { for (; i < args.length; i++) {
...@@ -105,7 +106,11 @@ public class RunScript { ...@@ -105,7 +106,11 @@ public class RunScript {
buff.append(args[i]); buff.append(args[i]);
} }
options = buff.toString(); options = buff.toString();
} else if (arg.equals("-help") || arg.equals("-?")) {
showUsage();
return;
} else { } else {
System.out.println("Unsupported option: " + arg);
showUsage(); showUsage();
return; return;
} }
......
...@@ -56,15 +56,16 @@ public class Script { ...@@ -56,15 +56,16 @@ public class Script {
String file = "backup.sql"; String file = "backup.sql";
String options1 = null, options2 = null; String options1 = null, options2 = null;
for (int i = 0; args != null && i < args.length; i++) { for (int i = 0; args != null && i < args.length; i++) {
if (args[i].equals("-url")) { String arg = args[i];
if (arg.equals("-url")) {
url = args[++i]; url = args[++i];
} else if (args[i].equals("-user")) { } else if (arg.equals("-user")) {
user = args[++i]; user = args[++i];
} else if (args[i].equals("-password")) { } else if (arg.equals("-password")) {
password = args[++i]; password = args[++i];
} else if (args[i].equals("-script")) { } else if (arg.equals("-script")) {
file = args[++i]; file = args[++i];
} else if (args[i].equals("-options")) { } else if (arg.equals("-options")) {
StringBuffer buff1 = new StringBuffer(); StringBuffer buff1 = new StringBuffer();
StringBuffer buff2 = new StringBuffer(); StringBuffer buff2 = new StringBuffer();
i++; i++;
...@@ -81,7 +82,11 @@ public class Script { ...@@ -81,7 +82,11 @@ public class Script {
} }
options1 = buff1.toString(); options1 = buff1.toString();
options2 = buff2.toString(); options2 = buff2.toString();
} else if (arg.equals("-help") || arg.equals("-?")) {
showUsage();
return;
} else { } else {
System.out.println("Unsupported option: " + arg);
showUsage(); showUsage();
return; return;
} }
......
...@@ -32,7 +32,7 @@ public class Server implements Runnable, ShutdownHandler { ...@@ -32,7 +32,7 @@ public class Server implements Runnable, ShutdownHandler {
private void showUsage(String a, PrintStream out) { private void showUsage(String a, PrintStream out) {
if (a != null) { if (a != null) {
out.println("Unknown option: " + a); out.println("Unsupported option: " + a);
out.println(); out.println();
} }
out.println("java "+getClass().getName() + " [options]"); out.println("java "+getClass().getName() + " [options]");
...@@ -141,93 +141,94 @@ public class Server implements Runnable, ShutdownHandler { ...@@ -141,93 +141,94 @@ public class Server implements Runnable, ShutdownHandler {
String tcpShutdownServer = ""; String tcpShutdownServer = "";
boolean startDefaultServers = true; boolean startDefaultServers = true;
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 arg = args[i];
if (a == null) { if (arg == null) {
continue; continue;
} else if ("-?".equals(a) || "-help".equals(a)) { } else if ("-?".equals(arg) || "-help".equals(arg)) {
showUsage(null, out); showUsage(null, out);
return EXIT_ERROR; return EXIT_ERROR;
} else if (a.startsWith("-web")) { } else if (arg.startsWith("-web")) {
if ("-web".equals(a)) { if ("-web".equals(arg)) {
startDefaultServers = false; startDefaultServers = false;
webStart = true; webStart = true;
} else if ("-webAllowOthers".equals(a)) { } else if ("-webAllowOthers".equals(arg)) {
i++; i++;
} else if ("-webPort".equals(a)) { } else if ("-webPort".equals(arg)) {
i++; i++;
} else if ("-webScript".equals(a)) { } else if ("-webScript".equals(arg)) {
i++; i++;
} else if ("-webSSL".equals(a)) { } else if ("-webSSL".equals(arg)) {
i++; i++;
} else { } else {
showUsage(a, out); showUsage(arg, out);
return EXIT_ERROR; return EXIT_ERROR;
} }
} else if ("-browser".equals(a)) { } else if ("-browser".equals(arg)) {
startDefaultServers = false; startDefaultServers = false;
browserStart = true; browserStart = true;
} else if (a.startsWith("-tcp")) { } else if (arg.startsWith("-tcp")) {
if ("-tcp".equals(a)) { if ("-tcp".equals(arg)) {
startDefaultServers = false; startDefaultServers = false;
tcpStart = true; tcpStart = true;
} else if ("-tcpAllowOthers".equals(a)) { } else if ("-tcpAllowOthers".equals(arg)) {
i++; i++;
} else if ("-tcpPort".equals(a)) { } else if ("-tcpPort".equals(arg)) {
i++; i++;
} else if ("-tcpSSL".equals(a)) { } else if ("-tcpSSL".equals(arg)) {
i++; i++;
} else if ("-tcpPassword".equals(a)) { } else if ("-tcpPassword".equals(arg)) {
tcpPassword = args[++i]; tcpPassword = args[++i];
} else if ("-tcpShutdown".equals(a)) { } else if ("-tcpShutdown".equals(arg)) {
startDefaultServers = false; startDefaultServers = false;
tcpShutdown = true; tcpShutdown = true;
tcpShutdownServer = args[++i]; tcpShutdownServer = args[++i];
} else if ("-tcpShutdownForce".equals(a)) { } else if ("-tcpShutdownForce".equals(arg)) {
tcpShutdownForce = Boolean.valueOf(args[++i]).booleanValue(); tcpShutdownForce = Boolean.valueOf(args[++i]).booleanValue();
} else { } else {
showUsage(a, out); showUsage(arg, out);
return EXIT_ERROR; return EXIT_ERROR;
} }
} else if (a.startsWith("-pg")) { } else if (arg.startsWith("-pg")) {
if ("-pg".equals(a)) { if ("-pg".equals(arg)) {
startDefaultServers = false; startDefaultServers = false;
pgStart = true; pgStart = true;
} else if ("-pgAllowOthers".equals(a)) { } else if ("-pgAllowOthers".equals(arg)) {
i++; i++;
} else if ("-pgPort".equals(a)) { } else if ("-pgPort".equals(arg)) {
i++; i++;
} else { } else {
showUsage(a, out); showUsage(arg, out);
return EXIT_ERROR; return EXIT_ERROR;
} }
} else if (a.startsWith("-ftp")) { } else if (arg.startsWith("-ftp")) {
if ("-ftp".equals(a)) { if ("-ftp".equals(arg)) {
startDefaultServers = false; startDefaultServers = false;
ftpStart = true; ftpStart = true;
} else if ("-ftpPort".equals(a)) { } else if ("-ftpPort".equals(arg)) {
i++; i++;
} else if ("-ftpDir".equals(a)) { } else if ("-ftpDir".equals(arg)) {
i++; i++;
} else if ("-ftpRead".equals(a)) { } else if ("-ftpRead".equals(arg)) {
i++; i++;
} else if ("-ftpWrite".equals(a)) { } else if ("-ftpWrite".equals(arg)) {
i++; i++;
} else if ("-ftpWritePassword".equals(a)) { } else if ("-ftpWritePassword".equals(arg)) {
i++; i++;
} else if ("-ftpTask".equals(a)) { } else if ("-ftpTask".equals(arg)) {
i++; i++;
} else { } else {
showUsage(a, out); showUsage(arg, out);
return EXIT_ERROR; return EXIT_ERROR;
} }
} else if (a.startsWith("-log")) { } else if (arg.startsWith("-log")) {
i++; i++;
} else if ("-baseDir".equals(a)) { } else if ("-baseDir".equals(arg)) {
i++; i++;
} else if ("-ifExists".equals(a)) { } else if ("-ifExists".equals(arg)) {
i++; i++;
} else { } else {
showUsage(a, out); out.println("Unsupported option: " + arg);
showUsage(arg, out);
return EXIT_ERROR; return EXIT_ERROR;
} }
} }
......
/*
* Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.tools;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.StringTokenizer;
import org.h2.engine.Constants;
import org.h2.message.Message;
import org.h2.util.ClassUtils;
import org.h2.util.JdbcUtils;
/**
* Interactive command line tool to access a database using JDBC.
*/
public class Shell {
private Connection conn;
private Statement stat;
private void showUsage() {
System.out.println("java " + getClass().getName() + " [-url <url> -user <user> -password <pwd> -driver <driver]");
System.out.println("See also http://h2database.com/javadoc/org/h2/tools/Prompt.html");
}
/**
* The command line interface for this tool. The options must be split into
* strings like this: "-user", "sa",... Options are case sensitive. The
* following options are supported:
* <ul>
* <li>-help or -? (print the list of options) </li>
* <li>-url jdbc:h2:... (database URL) </li>
* <li>-user username </li>
* <li>-password password </li>
* <li>-driver driver the JDBC driver class name (not required for H2)
* </li>
* </ul>
*
* @param args the command line arguments
* @throws SQLException
*/
public static void main(String[] args) throws SQLException {
new Shell().run(args);
}
private void run(String[] args) throws SQLException {
String url = null;
String user = "";
String password = "";
for (int i = 0; args != null && i < args.length; i++) {
if (args[i].equals("-url")) {
url = args[++i];
} else if (args[i].equals("-user")) {
user = args[++i];
} else if (args[i].equals("-password")) {
password = args[++i];
} else if (args[i].equals("-driver")) {
String driver = args[++i];
try {
ClassUtils.loadUserClass(driver);
} catch (ClassNotFoundException e) {
throw Message.convert(e);
}
} else {
System.out.println("Unsupported option: " + args[i]);
showUsage();
return;
}
}
if (url != null) {
org.h2.Driver.load();
conn = DriverManager.getConnection(url, user, password);
}
promptLoop();
}
private void showHelp() {
System.out.println("Commands are case insensitive; SQL statements end with ';'");
System.out.println("HELP or ? - Display this help");
System.out.println("CONNECT - Connect to a database. Optional arguments: url, user, password");
System.out.println("DRIVER - Load a JDBC driver class (usually not required)");
System.out.println("QUIT or EXIT - End this program");
System.out.println();
}
private void promptLoop() {
System.out.println();
System.out.println("Welcome to the H2 Shell " + Constants.getVersion());
showHelp();
String statement = null;
while (true) {
try {
if (statement == null) {
System.out.print("sql> ");
} else {
System.out.print("...> ");
}
String line = readLine();
if (line == null) {
break;
}
line = line.trim();
if (line.length() == 0) {
continue;
}
boolean end = line.endsWith(";");
if (end) {
line = line.substring(0, line.length() - 1).trim();
}
String upper = line.toUpperCase();
if ("EXIT".equals(upper) || "QUIT".equals(upper)) {
break;
} else if ("HELP".equals(upper) || "?".equals(upper)) {
showHelp();
} else {
if (statement == null) {
if (upper.startsWith("DRIVER")) {
loadDriver(line);
} else if (upper.startsWith("CONNECT")) {
conn = connect(line);
stat = conn.createStatement();
} else {
statement = line;
}
} else {
statement = statement + " " + line;
}
if (end) {
execute(statement);
statement = null;
}
}
} catch (SQLException e) {
System.out.println("SQL Exception: " + e.getMessage());
statement = null;
} catch (IOException e) {
System.out.println(e.getMessage());
break;
} catch (Exception e) {
System.out.println("Exception: " + e.toString());
e.printStackTrace();
break;
}
}
if (conn != null) {
try {
conn.close();
System.out.println("Connection closed");
} catch (SQLException e) {
System.out.println("SQL Exception:");
e.printStackTrace();
}
}
}
private void execute(String sql) throws SQLException {
if (stat == null) {
System.out.println("Not connected; type CONNECT to open a connection");
return;
}
stat.execute(sql);
}
private void loadDriver(String statement) throws IOException, ClassNotFoundException, SQLException {
StringTokenizer tokenizer = new StringTokenizer(statement);
tokenizer.nextToken();
String driver;
if (tokenizer.hasMoreTokens()) {
driver = tokenizer.nextToken();
} else {
System.out.print("URL: ");
driver = readLine();
}
ClassUtils.loadUserClass(driver);
}
private Connection connect(String statement) throws IOException, SQLException {
StringTokenizer tokenizer = new StringTokenizer(statement);
tokenizer.nextToken();
String url, user, password;
if (tokenizer.hasMoreTokens()) {
url = tokenizer.nextToken();
} else {
System.out.print("URL : ");
url = readLine();
}
if (tokenizer.hasMoreTokens()) {
user = tokenizer.nextToken();
} else {
System.out.print("User : ");
user = readLine();
}
if (tokenizer.hasMoreTokens()) {
password = tokenizer.nextToken();
} else {
password = readPassword();
}
Connection conn = JdbcUtils.getConnection(null, url, user, password);
System.out.println("Connected");
return conn;
}
private String readPassword() throws IOException {
class PasswordHider extends Thread {
volatile boolean stop;
public void run() {
while (!stop) {
System.out.print("\b\b><");
try {
Thread.sleep(10);
} catch (InterruptedException e) {
}
}
}
}
PasswordHider thread = new PasswordHider();
thread.start();
System.out.print("Password: > ");
String p = readLine();
thread.stop = true;
try {
thread.join();
} catch (InterruptedException e) {
// ignore
}
System.out.print("\b\b");
return p;
}
private String readLine() throws IOException {
String line = new BufferedReader(new InputStreamReader(System.in)).readLine();
if (line == null) {
throw new IOException("Aborted");
}
return line;
}
}
/*
* Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.util;
/**
* This class tries to automatically load the right JDBC driver for a given
* database URL.
*/
public class JdbcDriverLoader {
private static final String[] DRIVERS = {
"jdbc:h2:", "org.h2.Driver",
"jdbc:firebirdsql:", "org.firebirdsql.jdbc.FBDriver",
"jdbc:db2:", "COM.ibm.db2.jdbc.net.DB2Driver",
"jdbc:oracle:", "oracle.jdbc.driver.OracleDriver",
"jdbc:microsoft:", "com.microsoft.jdbc.sqlserver.SQLServerDriver",
"jdbc:sqlserver:", "com.microsoft.sqlserver.jdbc.SQLServerDriver",
"jdbc:postgresql:", "org.postgresql.Driver",
"jdbc:mysql:", "com.mysql.jdbc.Driver",
"jdbc:derby://", "org.apache.derby.jdbc.ClientDriver",
"jdbc:derby:", "org.apache.derby.jdbc.EmbeddedDriver",
"jdbc:hsqldb:", "org.hsqldb.jdbcDriver"
};
public static void load(String url) throws ClassNotFoundException {
for (int i = 0; i < DRIVERS.length; i += 2) {
String prefix = DRIVERS[i];
if (url.startsWith(prefix)) {
Class.forName(DRIVERS[i + 1]);
break;
}
}
}
}
...@@ -94,8 +94,10 @@ public class JdbcUtils { ...@@ -94,8 +94,10 @@ public class JdbcUtils {
} }
public static Connection getConnection(String driver, String url, Properties prop) throws SQLException { public static Connection getConnection(String driver, String url, Properties prop) throws SQLException {
if (!StringUtils.isNullOrEmpty(driver)) {
try { try {
if (StringUtils.isNullOrEmpty(driver)) {
JdbcDriverLoader.load(url);
} else {
Class d = ClassUtils.loadUserClass(driver); Class d = ClassUtils.loadUserClass(driver);
if (java.sql.Driver.class.isAssignableFrom(d)) { if (java.sql.Driver.class.isAssignableFrom(d)) {
return DriverManager.getConnection(url, prop); return DriverManager.getConnection(url, prop);
...@@ -124,12 +126,12 @@ public class JdbcUtils { ...@@ -124,12 +126,12 @@ public class JdbcUtils {
// Don't know, but maybe it loaded a JDBC Driver // Don't know, but maybe it loaded a JDBC Driver
return DriverManager.getConnection(url, prop); return DriverManager.getConnection(url, prop);
} }
}
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
throw Message.getSQLException(ErrorCode.CLASS_NOT_FOUND_1, new String[]{driver}, e); throw Message.getSQLException(ErrorCode.CLASS_NOT_FOUND_1, new String[]{driver}, e);
} catch (NoClassDefFoundError e) { } catch (NoClassDefFoundError e) {
throw Message.getSQLException(ErrorCode.CLASS_NOT_FOUND_1, new String[]{driver}, e); throw Message.getSQLException(ErrorCode.CLASS_NOT_FOUND_1, new String[]{driver}, e);
} }
}
return DriverManager.getConnection(url, prop); return DriverManager.getConnection(url, prop);
} }
......
...@@ -20,6 +20,7 @@ import org.h2.message.Message; ...@@ -20,6 +20,7 @@ import org.h2.message.Message;
public class ObjectUtils { public class ObjectUtils {
public static Integer getInteger(int x) { public static Integer getInteger(int x) {
// actually this method is available in JDK15
//#ifdef JDK16 //#ifdef JDK16
/* /*
if(true) if(true)
......
...@@ -159,15 +159,36 @@ java org.h2.test.TestAll timer ...@@ -159,15 +159,36 @@ java org.h2.test.TestAll timer
/* /*
new TestCrashAPI().init(test).testCase(2046453618); write to system table before adding to internal data structures
//new TestCrashAPI().init(test).testCase(2046453618);
Allow to set all passwords as parameters MiniConnectionPoolManager
Remove Parser.readString()
Hi,
Thanks a lot for your help! I can now also reproduce this problem. It only happens when using LOG=2,
and deleting or updating all rows of a table. There is a workaround (beside not using LOG=1):
System.setProperty("h2.reuseSpaceQuickly", "false");
or java -Dh2.reuseSpaceQuickly=false
I will fix this for the next release.
Regards,
Thomas
--------------
scheduler: what if invoke takes more than...
scheduler: log at startup next 5
scheduler: add an a cron functionality
performance of drop table / index is slow
(when deleting a lot of rows randomly?)
use a default delay of 1 second before closing a database.
more tests with disk based select distinct; order by: more tests with disk based select distinct; order by:
select distinct x from system_range(1, 200000); select distinct x from system_range(1, 200000);
DROP TABLE TEST; DROP TABLE TEST;
CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255), VALUE DECIMAL(10,2)); CREATE TABLE TEST(ID INT PRIMARY KEY,
NAME VARCHAR(255), VALUE DECIMAL(10,2));
INSERT INTO TEST VALUES(1,'Apples',1.20), INSERT INTO TEST VALUES(1,'Apples',1.20),
(2,'Oranges',2.05), (2,'Oranges',2.05),
(3,'Cherries',5.10), (3,'Cherries',5.10),
...@@ -183,6 +204,8 @@ CREATE TABLE p(d DATE); ...@@ -183,6 +204,8 @@ CREATE TABLE p(d DATE);
INSERT INTO p VALUES('0000-01-01'); INSERT INTO p VALUES('0000-01-01');
INSERT INTO p VALUES('0001-01-01'); INSERT INTO p VALUES('0001-01-01');
C:\temp\db\diff.patch
out of memory problem: out of memory problem:
java -XX:+HeapDumpOnOutOfMemoryError -Xmx1024m java -XX:+HeapDumpOnOutOfMemoryError -Xmx1024m
-cp bin/h2.jar org.h2.tools.Server -log true -cp bin/h2.jar org.h2.tools.Server -log true
...@@ -193,51 +216,47 @@ CREATE TABLE test (field1 number(10) not null, field2 number(8)); ...@@ -193,51 +216,47 @@ CREATE TABLE test (field1 number(10) not null, field2 number(8));
create index idx_number1 on test(field1); create index idx_number1 on test(field1);
The table 'test' contains a little over 100.000.000 records. The table 'test' contains a little over 100.000.000 records.
Read HenPlus features
http://henplus.sourceforge.net/
better document DataSource usage in an own section in the Tutorial.
Including Pooling if possible
link to or include
http://www.source-code.biz/snippets/java/8.htm
add regular javadocs to the homepage
the database should be kept open for a longer time when using the server mode
add link to new in use, links
Javadocs: for each tool, add a copy & paste sample in the class level
Add google site search to web page
merge query and result frames merge query and result frames
in-place auto-complete in-place auto-complete
scheduler: what if invoke takes more than...
scheduler: log at startup next 5
scheduler: add an a cron functionality
test with: test with:
- large varchar columns (40 KB) - large varchar columns (40 KB)
- not closing the database - not closing the database
read uncommitted and multi-threaded mode at the same time is dangerous read uncommitted and multi-threaded mode at the same time is dangerous
add @author
test multi-threaded kernel fulltext test multi-threaded kernel fulltext
fix or disable the linear hash index
Can sometimes not delete log file? need test case Can sometimes not delete log file? need test case
Add where required // TODO: change in version 1.1 Add where required // TODO: change in version 1.1
History: History:
A first (experimental) implementation of a Shell tools is now included (org.h2.tools.Shell).
Performance was very slow when using LOG=2 and deleting or
updating all rows of a table in a loop. Fixed.
ALTER TABLE or CREATE TABLE now support parameters for the password field.
The linear hash has been removed. It was always slower than the b-tree index,
and there were some bugs that would be hard to fix.
TRACE_LEVEL_ settings are no longer persistent. This was a problem
when database initialization code caused a lot of logging.
Fulltext search (native implementation): The words table is no longer
an in-memory table because this caused memory problems in some cases.
It was possible to create a role with the name as an existing user
(but not vice versa). This is not allowed any more.
Roadmap: Roadmap:
SET LOG_SYSTEM {NATIVE|LOG4J|COMMONS|DRIVER_MANAGER}
Fluent API for tools: Server.createTcpServer().setPort(9081).setPassword(password).start();
console features:
- reset?
- use StringBuffer to append (copy and paste problems)
- password mask option
- result set: two modes (list and table)
- Show Tables of MySQL and Show Fields (also ij)
(not required for H2) > not required for most databases
*/ */
......
...@@ -12,6 +12,8 @@ import java.sql.PreparedStatement; ...@@ -12,6 +12,8 @@ import java.sql.PreparedStatement;
import java.sql.Statement; import java.sql.Statement;
import java.util.HashMap; import java.util.HashMap;
import org.h2.util.JdbcDriverLoader;
/** /**
* A simple wrapper around the JDBC API. * A simple wrapper around the JDBC API.
* Currently used for testing. * Currently used for testing.
...@@ -23,34 +25,13 @@ import java.util.HashMap; ...@@ -23,34 +25,13 @@ import java.util.HashMap;
*/ */
public class Db { public class Db {
private static final String[] DRIVERS = {
"jdbc:h2:", "org.h2.Driver",
"jdbc:firebirdsql:", "org.firebirdsql.jdbc.FBDriver",
"jdbc:db2:", "COM.ibm.db2.jdbc.net.DB2Driver",
"jdbc:oracle:", "oracle.jdbc.driver.OracleDriver",
"jdbc:microsoft:", "com.microsoft.jdbc.sqlserver.SQLServerDriver",
"jdbc:sqlserver:", "com.microsoft.sqlserver.jdbc.SQLServerDriver",
"jdbc:postgresql:", "org.postgresql.Driver",
"jdbc:mysql:", "com.mysql.jdbc.Driver",
"jdbc:derby://", "org.apache.derby.jdbc.ClientDriver",
"jdbc:derby:", "org.apache.derby.jdbc.EmbeddedDriver",
"jdbc:hsqldb:", "org.hsqldb.jdbcDriver"
};
private Connection conn; private Connection conn;
private Statement stat; private Statement stat;
private HashMap prepared = new HashMap(); private HashMap prepared = new HashMap();
private long start;
public static Db open(String url, String user, String password) { public static Db open(String url, String user, String password) {
try { try {
for (int i = 0; i < DRIVERS.length; i += 2) { JdbcDriverLoader.load(url);
String prefix = DRIVERS[i];
if (url.startsWith(prefix)) {
Class.forName(DRIVERS[i + 1]);
break;
}
}
return new Db(DriverManager.getConnection(url, user, password)); return new Db(DriverManager.getConnection(url, user, password));
} catch (Exception e) { } catch (Exception e) {
throw convert(e); throw convert(e);
...@@ -152,11 +133,4 @@ public class Db { ...@@ -152,11 +133,4 @@ public class Db {
return new Error("Error: " + e.toString(), e); return new Error("Error: " + e.toString(), e);
} }
public void startTime() {
start = System.currentTimeMillis();
}
public void printTime(String s) {
System.out.println(s + ": " + (System.currentTimeMillis() - start));
}
} }
...@@ -33,8 +33,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger { ...@@ -33,8 +33,7 @@ public class TestTriggersConstraints extends TestBase implements Trigger {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("DROP TABLE IF EXISTS TEST"); stat.execute("DROP TABLE IF EXISTS TEST");
stat.execute("create table test(id int primary key, parent int)"); stat.execute("create table test(id int primary key, parent int)");
stat stat.execute("alter table test add constraint test_parent_id foreign key(parent) references test (id) on delete cascade");
.execute("alter table test add constraint test_parent_id foreign key(parent) references test (id) on delete cascade");
stat.execute("insert into test select x, x/2 from system_range(0, 100)"); stat.execute("insert into test select x, x/2 from system_range(0, 100)");
stat.execute("delete from test"); stat.execute("delete from test");
checkSingleValue(stat, "select count(*) from test", 0); checkSingleValue(stat, "select count(*) from test", 0);
......
...@@ -32,14 +32,14 @@ public class TestSampleApps extends TestBase { ...@@ -32,14 +32,14 @@ public class TestSampleApps extends TestBase {
testApp(org.h2.samples.TriggerSample.class, null, "The sum is 20.00"); testApp(org.h2.samples.TriggerSample.class, null, "The sum is 20.00");
// tools // tools
testApp(org.h2.tools.ChangePassword.class, new String[] { "-?" }, testApp(org.h2.tools.ChangePassword.class, new String[] { "-help" },
"java org.h2.tools.ChangePassword [-dir <dir>] " "java org.h2.tools.ChangePassword [-dir <dir>] "
+ "[-db <database>] [-cipher <cipher>] [-decrypt <pwd>] [-encrypt <pwd>] [-quiet]\n" + "[-db <database>] [-cipher <cipher>] [-decrypt <pwd>] [-encrypt <pwd>] [-quiet]\n"
+ "See also http://h2database.com/javadoc/org/h2/tools/ChangePassword.html"); + "See also http://h2database.com/javadoc/org/h2/tools/ChangePassword.html");
testApp(org.h2.tools.ChangePassword.class, null, "java org.h2.tools.ChangePassword [-dir <dir>] " testApp(org.h2.tools.ChangePassword.class, null, "java org.h2.tools.ChangePassword [-dir <dir>] "
+ "[-db <database>] [-cipher <cipher>] [-decrypt <pwd>] [-encrypt <pwd>] [-quiet]\n" + "[-db <database>] [-cipher <cipher>] [-decrypt <pwd>] [-encrypt <pwd>] [-quiet]\n"
+ "See also http://h2database.com/javadoc/org/h2/tools/ChangePassword.html"); + "See also http://h2database.com/javadoc/org/h2/tools/ChangePassword.html");
testApp(org.h2.tools.DeleteDbFiles.class, new String[] { "-?" }, testApp(org.h2.tools.DeleteDbFiles.class, new String[] { "-help" },
"java org.h2.tools.DeleteDbFiles [-dir <dir>] [-db <database>] [-quiet]\n" "java org.h2.tools.DeleteDbFiles [-dir <dir>] [-db <database>] [-quiet]\n"
+ "See also http://h2database.com/javadoc/org/h2/tools/DeleteDbFiles.html"); + "See also http://h2database.com/javadoc/org/h2/tools/DeleteDbFiles.html");
} }
......
...@@ -72,7 +72,7 @@ public class TestTools extends TestBase { ...@@ -72,7 +72,7 @@ public class TestTools extends TestBase {
result = runServer(new String[]{"-xy"}, 1); result = runServer(new String[]{"-xy"}, 1);
check(result.indexOf("[options]") >= 0); check(result.indexOf("[options]") >= 0);
check(result.indexOf("Unknown option") >= 0); check(result.indexOf("Unsupported option") >= 0);
result = runServer(new String[]{"-tcp", "-tcpAllowOthers", "false", "-tcpPort", "9001", "-tcpPassword", "abc"}, 0); result = runServer(new String[]{"-tcp", "-tcpAllowOthers", "false", "-tcpPort", "9001", "-tcpPassword", "abc"}, 0);
check(result.indexOf("tcp://") >= 0); check(result.indexOf("tcp://") >= 0);
check(result.indexOf(":9001") >= 0); check(result.indexOf(":9001") >= 0);
......
...@@ -483,4 +483,5 @@ year yen yes yet yield yielding ymd you your yourkit yourself ytd yuml yusuke ...@@ -483,4 +483,5 @@ year yen yes yet yield yielding ymd you your yourkit yourself ytd yuml yusuke
yyyy zeile zero zeros zeta zip zloty zone zwj zwnj yyyy zeile zero zeros zeta zip zloty zone zwj zwnj
cron ide pageview track gat analytics tracker implicitly ignores pro providers cron ide pageview track gat analytics tracker implicitly ignores pro providers
tmpdir mini tmpdir mini owns accordingly snippets receiving rainbow pools groupware biz
\ No newline at end of file greenwich
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论