提交 3d40aad2 authored 作者: Thomas Mueller's avatar Thomas Mueller

The build converts the javadocs to a resource.

上级 25d38fde
org.h2.tools.Backup=Creates a backup of a database.
org.h2.tools.Backup.main=Options are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-file <filename>] The target file name (default\: backup.zip)\n[-dir <dir>] The source directory (default\: .)\n[-db <database>] Source database; not required if there is only one\n[-quiet] Do not print progress information
org.h2.tools.ChangeFileEncryption=Allows changing the database file encryption password or algorithm.\nThis tool can not be used to change a password of a user.
org.h2.tools.ChangeFileEncryption.main=Options are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-cipher type] The encryption type (AES or XTEA)\n[-dir <dir>] The database directory (default\: .)\n[-db <database>] Database name (all databases if not set)\n[-decrypt <pwd>] The decryption password (if not set\: not yet encrypted)\n[-encrypt <pwd>] The encryption password (if not set\: do not encrypt)\n[-quiet] Do not print progress information
org.h2.tools.ConvertTraceFile=Converts a .trace.db file to a SQL script and Java source code.\nSQL statement statistics are listed as well.
org.h2.tools.ConvertTraceFile.main=Options are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-traceFile <file>] The trace file name (default\: test.trace.db)\n[-script <file>] The script file name (default\: test.sql)\n[-javaClass <file>] The Java directory and class file name (default\: Test)
org.h2.tools.CreateCluster=Creates a cluster from a standalone database.\nCopies a database to another location if required.
org.h2.tools.CreateCluster.main=Options are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-urlSource <url>] The database URL of the source database (jdbc\:h2\:...)\n[-urlTarget <url>] The database URL of the target database (jdbc\:h2\:...)\n[-user <user>] The user name (default\: sa)\n[-password <pwd>] The password\n[-serverList <list>] The comma separated list of host names or IP addresses
org.h2.tools.DeleteDbFiles=Deletes all files belonging to a database.\nThe database must be closed before calling this tool.
org.h2.tools.DeleteDbFiles.main=Options are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-dir <dir>] The directory (default\: .)\n[-db <database>] The database name\n[-quiet] Do not print progress information
org.h2.tools.Recover=Helps recovering a corrupted database.
org.h2.tools.Recover.main=Options are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-dir <dir>] The directory (default\: .)\n[-db <database>] The database name (all databases if not set)\n[-trace] Print additional trace information
org.h2.tools.Restore=Restores a H2 database by extracting the database files from a .zip file.
org.h2.tools.Restore.main=Options are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-file <filename>] The source file name (default\: backup.zip)\n[-dir <dir>] The target directory (default\: .)\n[-db <database>] The target database name (as stored if not set)\n[-quiet] Do not print progress information
org.h2.tools.RunScript=Runs a SQL script against a database.
org.h2.tools.RunScript.main=Options are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-url <url>] The database URL (jdbc\:...)\n[-user <user>] The user name (default\: sa)\n[-password <pwd>] The password\n[-script <file>] The script file to run (default\: backup.sql)\n[-driver <class>] The JDBC driver class to use (not required in most cases)\n[-showResults] Show the statements and the results of queries\n[-checkResults] Check if the query results match the expected results\n[-options ...] A list of options (only for embedded H2, see RUNSCRIPT)
org.h2.tools.Script=Creates a SQL script file by extracting the schema and data of a database.
org.h2.tools.Script.main=Options are case sensitive. Supported options are\:\n[-help] or [-?] Print the list of options\n[-url <url>] The database URL (jdbc\:...)\n[-user <user>] The user name (default\: sa)\n[-password <pwd>] The password\n[-script <file>] The target script file name (default\: backup.sql)\n[-options ...] A list of options (only for embedded H2, see RUNSCRIPT)\n[-quiet] Do not print progress information
......@@ -24,34 +24,28 @@ import org.h2.util.IOUtils;
import org.h2.util.Tool;
/**
* Backs up a H2 database by creating a .zip file from the database files.
* Creates a backup of a database.
* @h2.resource
*/
public class Backup extends Tool {
private void showUsage() {
out.println("Creates a backup of a database.");
out.println("java "+getClass().getName() + "\n" +
" [-file <filename>] The target file name (default: backup.zip)\n" +
" [-dir <dir>] Source directory (default: .)\n" +
" [-db <database>] Source database name\n" +
" [-quiet] Do not print progress information");
out.println("See also http://h2database.com/javadoc/" + getClass().getName().replace('.', '/') + ".html");
}
/**
* The command line interface for this tool.
* The options must be split into strings like this: "-db", "test",...
* Options are case sensitive. The following options are supported:
* <ul>
* <li>-help or -? (print the list of options)
* </li><li>-file filename (the default is backup.zip)
* </li><li>-dir database directory (the default is the current directory)
* </li><li>-db database name (not required if there is only one database)
* </li><li>-quiet does not print progress information
* </li></ul>
* Options are case sensitive. Supported options are:
* <table>
* <tr><td>[-help] or [-?]</td>
* <td>Print the list of options</td></tr>
* <tr><td>[-file &lt;filename&gt;]</td>
* <td>The target file name (default: backup.zip)</td></tr>
* <tr><td>[-dir &lt;dir&gt;]</td>
* <td>The source directory (default: .)</td></tr>
* <tr><td>[-db &lt;database&gt;]</td>
* <td>Source database; not required if there is only one</td></tr>
* <tr><td>[-quiet]</td>
* <td>Do not print progress information</td></tr>
* </table>
* @h2.resource
*
* @param args the command line arguments
* @throws SQLException
*/
public static void main(String[] args) throws SQLException {
new Backup().run(args);
......
......@@ -17,9 +17,10 @@ import org.h2.util.FileUtils;
import org.h2.util.Tool;
/**
* A tools to change, remove or set a file password of a database without
* opening it. The encryption algorithm can be changed as well. It can not be
* used to change a password of a user.
* Allows changing the database file encryption password or algorithm.
* <br />
* This tool can not be used to change a password of a user.
* @h2.resource
*/
public class ChangeFileEncryption extends Tool {
......@@ -28,34 +29,27 @@ public class ChangeFileEncryption extends Tool {
private byte[] decrypt;
private byte[] encrypt;
private void showUsage() {
out.println("Allows changing the database file encryption password or algorithm.");
out.println("java "+getClass().getName() + "\n" +
" -cipher <type> AES or XTEA\n" +
" [-dir <dir>] The database directory (default: .)\n" +
" [-db <database>] The database name (default: all databases)\n" +
" [-decrypt <pwd>] The decryption password (default: the database is not yet encrypted)\n" +
" [-encrypt <pwd>] The encryption password (default: the database should not be encrypted)\n" +
" [-quiet] Do not print progress information");
out.println("See also http://h2database.com/javadoc/" + getClass().getName().replace('.', '/') + ".html");
}
/**
* The command line interface for this tool.
* The options must be split into strings like this: "-db", "test",...
* Options are case sensitive. The following options are supported:
* <ul>
* <li>-help or -? (print the list of options)
* </li><li>-dir database directory (the default is the current directory)
* </li><li>-db database name (all databases if no name is specified)
* </li><li>-cipher type (AES or XTEA)
* </li><li>-decrypt password (null if the database is not encrypted)
* </li><li>-encrypt password (null if the database should not be encrypted)
* </li><li>-quiet does not print progress information
* </li></ul>
* Options are case sensitive. Supported options are:
* <table>
* <tr><td>[-help] or [-?]</td>
* <td>Print the list of options</td></tr>
* <tr><td>[-cipher type]</td>
* <td>The encryption type (AES or XTEA)</td></tr>
* <tr><td>[-dir &lt;dir&gt;]</td>
* <td>The database directory (default: .)</td></tr>
* <tr><td>[-db &lt;database&gt;]</td>
* <td>Database name (all databases if not set)</td></tr>
* <tr><td>[-decrypt &lt;pwd&gt;]</td>
* <td>The decryption password (if not set: not yet encrypted)</td></tr>
* <tr><td>[-encrypt &lt;pwd&gt;]</td>
* <td>The encryption password (if not set: do not encrypt)</td></tr>
* <tr><td>[-quiet]</td>
* <td>Do not print progress information</td></tr>
* </table>
* @h2.resource
*
* @param args the command line arguments
* @throws SQLException
*/
public static void main(String[] args) throws SQLException {
new ChangeFileEncryption().run(args);
......
......@@ -21,8 +21,10 @@ import org.h2.util.StringUtils;
import org.h2.util.Tool;
/**
* Convert a trace file to a java class.
* This is required because the find command truncates lines.
* Converts a .trace.db file to a SQL script and Java source code.
* <br />
* SQL statement statistics are listed as well.
* @h2.resource
*/
public class ConvertTraceFile extends Tool {
......@@ -54,28 +56,21 @@ public class ConvertTraceFile extends Tool {
}
}
private void showUsage() {
out.println("Converts a .trace.db file to a SQL script and Java source code.");
out.println("java "+getClass().getName() + "\n" +
" [-traceFile <file>] The trace file name (default: test.trace.db)\n" +
" [-script <file>] The script file name (default: test.sql)\n" +
" [-javaClass <file>] The Java directory and class file name (default: Test)");
out.println("See also http://h2database.com/javadoc/" + getClass().getName().replace('.', '/') + ".html");
}
/**
* The command line interface for this tool. The options must be split into
* strings like this: "-traceFile", "test.trace.db",... Options are case
* sensitive. The following options are supported:
* <ul>
* <li>-help or -? (print the list of options) </li>
* <li>-traceFile filename (the default is test.trace.db) </li>
* <li>-script filename (the default is test.sql) </li>
* <li>-javaClass className (the default is Test) </li>
* </ul>
* Options are case sensitive. Supported options are:
* <table>
* <tr><td>[-help] or [-?]</td>
* <td>Print the list of options</td></tr>
* <tr><td>[-traceFile &lt;file&gt;]</td>
* <td>The trace file name (default: test.trace.db)</td></tr>
* <tr><td>[-script &lt;file&gt;]</td>
* <td>The script file name (default: test.sql)</td></tr>
* <tr><td>[-javaClass &lt;file&gt;]</td>
* <td>The Java directory and class file name (default: Test)</td></tr>
* </table>
* @h2.resource
*
* @param args the command line arguments
* @throws Exception
*/
public static void main(String[] args) throws SQLException {
new ConvertTraceFile().run(args);
......
......@@ -16,38 +16,32 @@ import org.h2.util.JdbcUtils;
import org.h2.util.Tool;
/**
* Tool to create a database cluster. This will copy a database to another
* location if required, and modify the cluster setting.
* Creates a cluster from a standalone database.
* <br />
* Copies a database to another location if required.
* @h2.resource
*/
public class CreateCluster extends Tool {
private void showUsage() {
out.println("Creates a cluster from a standalone database.");
out.println("java "+getClass().getName() + "\n" +
" -urlSource <url> The database URL of the source database (jdbc:h2:...)\n" +
" -urlTarget <url> The database URL of the target database (jdbc:h2:...)\n" +
" -user <user> The user name\n" +
" [-password <pwd>] The password\n" +
" -serverList <list> The comma separated list of host names or IP addresses");
out.println("See also http://h2database.com/javadoc/" + getClass().getName().replace('.', '/') + ".html");
}
/**
* The command line interface for this tool. The options must be split into
* strings like this: "-urlSource", "jdbc:h2:test",... Options are case
* sensitive. The following options are supported:
* <ul>
* <li>-help or -? (print the list of options) </li>
* <li>-urlSource jdbc:h2:... (the database URL of the source database)
* </li>
* <li>-urlTarget jdbc:h2:... (the database URL of the target database)
* </li><li>-user (the user name)
* </li><li>-password (the password)
* </li><li>-serverList (the server list)
* </li></ul>
* Options are case sensitive. Supported options are:
* <table>
* <tr><td>[-help] or [-?]</td>
* <td>Print the list of options</td></tr>
* <tr><td>[-urlSource &lt;url&gt;]</td>
* <td>The database URL of the source database (jdbc:h2:...)</td></tr>
* <tr><td>[-urlTarget &lt;url&gt;]</td>
* <td>The database URL of the target database (jdbc:h2:...)</td></tr>
* <tr><td>[-user &lt;user&gt;]</td>
* <td>The user name (default: sa)</td></tr>
* <tr><td>[-password &lt;pwd&gt;]</td>
* <td>The password</td></tr>
* <tr><td>[-serverList &lt;list&gt;]</td>
* <td>The comma separated list of host names or IP addresses</td></tr>
* </table>
* @h2.resource
*
* @param args the command line arguments
* @throws SQLException
*/
public static void main(String[] args) throws SQLException {
new CreateCluster().run(args);
......@@ -56,7 +50,7 @@ public class CreateCluster extends Tool {
public void run(String[] args) throws SQLException {
String urlSource = null;
String urlTarget = null;
String user = null;
String user = "sa";
String password = "";
String serverList = null;
for (int i = 0; args != null && i < args.length; i++) {
......
......@@ -16,33 +16,28 @@ import org.h2.util.FileUtils;
import org.h2.util.Tool;
/**
* Delete the database files. The database must be closed before calling this
* tool.
* Deletes all files belonging to a database.
* <br />
* The database must be closed before calling this tool.
* @h2.resource
*/
public class DeleteDbFiles extends Tool {
private void showUsage() {
out.println("Deletes all files belonging to a database.");
out.println("java "+getClass().getName() + "\n" +
" [-dir <dir>] The directory (default: .)\n" +
" [-db <database>] The database name\n" +
" [-quiet] Do not print progress information");
out.println("See also http://h2database.com/javadoc/" + getClass().getName().replace('.', '/') + ".html");
}
/**
* The command line interface for this tool.
* The options must be split into strings like this: "-db", "test",...
* Options are case sensitive. The following options are supported:
* <ul>
* <li>-help or -? (print the list of options)
* </li><li>-dir database directory (the default is the current directory)
* </li><li>-db database name (all databases if no name is specified)
* </li><li>-quiet does not print progress information
* </li></ul>
* Options are case sensitive. Supported options are:
* <table>
* <tr><td>[-help] or [-?]</td>
* <td>Print the list of options</td></tr>
* <tr><td>[-dir &lt;dir&gt;]</td>
* <td>The directory (default: .)</td></tr>
* <tr><td>[-db &lt;database&gt;]</td>
* <td>The database name</td></tr>
* <tr><td>[-quiet]</td>
* <td>Do not print progress information</td></tr>
* </table>
* @h2.resource
*
* @param args the command line arguments
* @throws SQLException
*/
public static void main(String[] args) throws SQLException {
new DeleteDbFiles().run(args);
......
......@@ -58,12 +58,8 @@ import org.h2.value.Value;
import org.h2.value.ValueLob;
/**
* Dumps the contents of a database file to a human readable text file. This
* text file can be used to recover most of the data. This tool does not open
* the database and can be used even if the database files are corrupted. A
* database can get corrupted if there is a bug in the database engine or file
* system software, or if an application writes into the database file that
* doesn't understand the the file format, or if there is a hardware problem.
* Helps recovering a corrupted database.
* @h2.resource
*/
public class Recover extends Tool implements DataHandler {
......@@ -80,33 +76,37 @@ public class Recover extends Tool implements DataHandler {
private HashMap tableMap;
private boolean remove;
private void showUsage() {
out.println("Helps recovering a corrupted database.");
out.println("java "+getClass().getName() + "\n" +
" [-dir <dir>] The directory (default: .)\n" +
" [-db <database>] The database name\n" +
" [-trace] Print additional trace information");
out.println("See also http://h2database.com/javadoc/" + getClass().getName().replace('.', '/') + ".html");
}
/**
* The command line interface for this tool.
* The options must be split into strings like this: "-db", "test",...
* Options are case sensitive. The following options are supported:
* <ul>
* <li>-help or -? (print the list of options)
* </li><li>-dir database directory (the default is the current directory)
* </li><li>-db database name (all databases if no name is specified)
* </li><li>-trace (print additional trace information while processing)
* </li></ul>
* Options are case sensitive. Supported options are:
* <table>
* <tr><td>[-help] or [-?]</td>
* <td>Print the list of options</td></tr>
* <tr><td>[-dir &lt;dir&gt;]</td>
* <td>The directory (default: .)</td></tr>
* <tr><td>[-db &lt;database&gt;]</td>
* <td>The database name (all databases if not set)</td></tr>
* <tr><td>[-trace]</td>
* <td>Print additional trace information</td></tr>
* </table>
* @h2.resource
*
* @param args the command line arguments
* @throws SQLException
*/
public static void main(String[] args) throws SQLException {
new Recover().run(args);
}
/**
* Dumps the contents of a database file to a human readable text file. This
* text file can be used to recover most of the data. This tool does not
* open the database and can be used even if the database files are
* corrupted. A database can get corrupted if there is a bug in the database
* engine or file system software, or if an application writes into the
* database file that doesn't understand the the file format, or if there is
* a hardware problem.
*
* @param args the command line arguments
*/
public void run(String[] args) throws SQLException {
String dir = ".";
String db = null;
......
......@@ -22,31 +22,27 @@ import org.h2.util.Tool;
/**
* Restores a H2 database by extracting the database files from a .zip file.
* @h2.resource
*/
public class Restore extends Tool {
private void showUsage() {
out.println("Restores a database backup.");
out.println("java "+getClass().getName() + "\n" +
" [-file <filename>] The source file name (default: backup.zip)\n" +
" [-dir <dir>] Target directory (default: .)\n" +
" [-db <database>] Target database name");
out.println("See also http://h2database.com/javadoc/" + getClass().getName().replace('.', '/') + ".html");
}
/**
* The command line interface for this tool.
* The options must be split into strings like this: "-db", "test",...
* Options are case sensitive. The following options are supported:
* <ul>
* <li>-help or -? (print the list of options)
* </li><li>-file filename (the default is backup.zip)
* </li><li>-dir database directory (the default is the current directory)
* </li><li>-db database name (as stored in the backup if no name is specified)
* </li></ul>
* Options are case sensitive. Supported options are:
* <table>
* <tr><td>[-help] or [-?]</td>
* <td>Print the list of options</td></tr>
* <tr><td>[-file &lt;filename&gt;]</td>
* <td>The source file name (default: backup.zip)</td></tr>
* <tr><td>[-dir &lt;dir&gt;]</td>
* <td>The target directory (default: .)</td></tr>
* <tr><td>[-db &lt;database&gt;]</td>
* <td>The target database name (as stored if not set)</td></tr>
* <tr><td>[-quiet]</td>
* <td>Do not print progress information</td></tr>
* </table>
* @h2.resource
*
* @param args the command line arguments
* @throws SQLException
*/
public static void main(String[] args) throws SQLException {
new Restore().run(args);
......
......@@ -30,70 +30,65 @@ import org.h2.util.StringUtils;
import org.h2.util.Tool;
/**
* Executes the contents of a SQL script file against a database.
* This tool is usually used to create a database from script.
* It can also be used to analyze performance problems by running
* the tool using Java profiler settings such as:
* <pre>
* java -Xrunhprof:cpu=samples ...
* </pre>
* Runs a SQL script against a database.
* @h2.resource
*/
public class RunScript extends Tool {
private boolean showResults;
private boolean checkResults;
private void showUsage() {
out.println("Runs a SQL script.");
out.println("java "+getClass().getName() + "\n" +
" -url <url> The database URL\n" +
" -user <user> The user name\n" +
" [-password <pwd>] The password\n" +
" [-script <file>] The script file to run (default: backup.sql)\n" +
" [-driver <class>] The JDBC driver class to use (not required in most cases)\n" +
" [-showResults] Show the statements and the results of queries\n" +
" [-checkResults] Check if the query results match the expected results\n" +
" [-options ...] A list of options (only for embedded H2, see RUNSCRIPT)");
out.println("See also http://h2database.com/javadoc/" + getClass().getName().replace('.', '/') + ".html");
/**
* Options are case sensitive. Supported options are:
* <table>
* <tr><td>[-help] or [-?]</td>
* <td>Print the list of options</td></tr>
* <tr><td>[-url &lt;url&gt;]</td>
* <td>The database URL (jdbc:...)</td></tr>
* <tr><td>[-user &lt;user&gt;]</td>
* <td>The user name (default: sa)</td></tr>
* <tr><td>[-password &lt;pwd&gt;]</td>
* <td>The password</td></tr>
* <tr><td>[-script &lt;file&gt;]</td>
* <td>The script file to run (default: backup.sql)</td></tr>
* <tr><td>[-driver &lt;class&gt;]</td>
* <td>The JDBC driver class to use (not required in most cases)</td></tr>
* <tr><td>[-showResults]</td>
* <td>Show the statements and the results of queries</td></tr>
* <tr><td>[-checkResults]</td>
* <td>Check if the query results match the expected results</td></tr>
* <tr><td>[-options ...]</td>
* <td>A list of options (only for embedded H2, see RUNSCRIPT)</td></tr>
* </table>
* @h2.resource
*
* @param args the command line arguments
*/
public static void main(String[] args) throws SQLException {
new RunScript().run(args);
}
/**
* 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>-script filename (default file name is backup.sql) </li>
* <li>-driver driver (the JDBC driver class name; not required for most
* databases) </li>
* <li>-showResults (show the statements and the results of queries)</li>
* <li>-checkResults (check if the query results match the expected results</li>
* <li>-options (to specify a list of options for the RUNSCRIPT command;
* only for H2 and only when using the embedded mode)</li>
* </ul>
* Executes the contents of a SQL script file against a database.
* This tool is usually used to create a database from script.
* It can also be used to analyze performance problems by running
* the tool using Java profiler settings such as:
* <pre>
* java -Xrunhprof:cpu=samples,depth=16 ...
* </pre>
* To include local files when using remote databases, use the special
* syntax:
*
* <pre>
* &#064;INCLUDE fileName
* </pre>
*
* This syntax is only supported by this tool. Embedded RUNSCRIPT SQL
* statements will be executed by the database.
*
* @param args the command line arguments
* @throws SQLException
*/
public static void main(String[] args) throws SQLException {
new RunScript().run(args);
}
public void run(String[] args) throws SQLException {
String url = null;
String user = null;
String user = "sa";
String password = "";
String script = "backup.sql";
String options = null;
......
......@@ -22,36 +22,31 @@ import org.h2.util.Tool;
/**
* Creates a SQL script file by extracting the schema and data of a database.
* @h2.resource
*/
public class Script extends Tool {
private void showUsage() {
out.println("Allows converting a database to a SQL script.");
out.println("java "+getClass().getName() + "\n" +
" -url <url> The database URL\n" +
" -user <user> The user name\n" +
" [-password <pwd>] The password\n" +
" [-script <file>] The script file to run (default: backup.sql)\n" +
" [-quiet] Do not print progress information\n" +
" [-options ...] The list of options (only for H2 embedded mode)");
out.println("See also http://h2database.com/javadoc/" + getClass().getName().replace('.', '/') + ".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>-script filename (default file name is backup.sql)
* </li><li>-options to specify a list of options (only for H2)
* </li></ul>
* Options are case sensitive. Supported options are:
* <table>
* <tr><td>[-help] or [-?]</td>
* <td>Print the list of options</td></tr>
* <tr><td>[-url &lt;url&gt;]</td>
* <td>The database URL (jdbc:...)</td></tr>
* <tr><td>[-user &lt;user&gt;]</td>
* <td>The user name (default: sa)</td></tr>
* <tr><td>[-password &lt;pwd&gt;]</td>
* <td>The password</td></tr>
* <tr><td>[-script &lt;file&gt;]</td>
* <td>The target script file name (default: backup.sql)</td></tr>
* <tr><td>[-options ...]</td>
* <td>A list of options (only for embedded H2, see RUNSCRIPT)</td></tr>
* <tr><td>[-quiet]</td>
* <td>Do not print progress information</td></tr>
* </table>
* @h2.resource
*
* @param args the command line arguments
* @throws SQLException
*/
public static void main(String[] args) throws SQLException {
new Script().run(args);
......@@ -59,7 +54,7 @@ public class Script extends Tool {
public void run(String[] args) throws SQLException {
String url = null;
String user = null;
String user = "sa";
String password = "";
String file = "backup.sql";
String options1 = null, options2 = null;
......@@ -99,7 +94,7 @@ public class Script extends Tool {
return;
}
}
if (url == null || user == null || file == null) {
if (url == null) {
showUsage();
return;
}
......
......@@ -6,8 +6,15 @@
*/
package org.h2.util;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Properties;
......@@ -87,4 +94,29 @@ public class SortedProperties extends Properties {
return prop;
}
/**
* Store a properties file. The header and the date is not written.
*
* @param fileName the target file name
*/
public synchronized void store(String fileName) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
store(out, null);
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
InputStreamReader reader = new InputStreamReader(in, "ISO8859-1");
LineNumberReader r = new LineNumberReader(reader);
FileWriter w = new FileWriter(fileName);
PrintWriter writer = new PrintWriter(new BufferedWriter(w));
while (true) {
String line = r.readLine();
if (line == null) {
break;
}
if (!line.startsWith("#")) {
writer.println(line);
}
}
writer.close();
}
}
......@@ -6,9 +6,11 @@
*/
package org.h2.util;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.sql.SQLException;
import java.util.Properties;
import org.h2.constant.SysProperties;
/**
......@@ -22,6 +24,8 @@ public abstract class Tool {
*/
protected PrintStream out = System.out;
private Properties resources;
/**
* Sets the standard output stream.
*
......@@ -57,6 +61,30 @@ public abstract class Tool {
out.println(buff.toString());
}
/**
* Print the usage of the tool. This method reads the description from the
* resource file.
*/
protected void showUsage() {
if (resources == null) {
resources = new Properties();
String resourceName = "/org/h2/res/javadoc.properties";
try {
byte[] buff = Resources.get(resourceName);
if (buff != null) {
resources.load(new ByteArrayInputStream(buff));
}
} catch (IOException e) {
out.println("Cannot load " + resourceName);
}
}
String className = getClass().getName();
out.println(resources.get(className));
out.println("Usage: java "+getClass().getName() + " <options>");
out.println(resources.get(className + ".main"));
out.println("See also http://h2database.com/javadoc/" + className.replace('.', '/') + ".html");
}
/**
* Read an argument and check if it is true (1), false (-1), or not (0).
* This method is used for compatibility with older versions only.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论