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

--no commit message

--no commit message
上级 7f06fba8
...@@ -199,10 +199,10 @@ database fails fast: a concurrent update exception is thrown. ...@@ -199,10 +199,10 @@ database fails fast: a concurrent update exception is thrown.
</p> </p>
<p> <p>
To use the MVCC feature, append MVCC=TRUE to the database URL: To use the MVCC feature, append MVCC=TRUE to the database URL:
</p>
<pre> <pre>
jdbc:h2:~/test;MVCC=TRUE jdbc:h2:~/test;MVCC=TRUE
</pre> </pre>
</p>
<p> <p>
The MVCC feature is not fully tested yet. The MVCC feature is not fully tested yet.
</p> </p>
...@@ -406,22 +406,28 @@ The Windows version of the PostgreSQL ODBC driver is available at ...@@ -406,22 +406,28 @@ The Windows version of the PostgreSQL ODBC driver is available at
<h3>Starting the Server</h3> <h3>Starting the Server</h3>
<p> <p>
After installing the ODBC driver, start the H2 Server using the command line: After installing the ODBC driver, start the H2 Server using the command line:
</p>
<pre> <pre>
java -cp h2.jar org.h2.tools.Server java -cp h2.jar org.h2.tools.Server
</pre> </pre>
<p>
The PG Server (PG for PostgreSQL protocol) is started as well. The PG Server (PG for PostgreSQL protocol) is started as well.
By default, databases are stored in the current working directory where the server is started. By default, databases are stored in the current working directory where the server is started.
Use -baseDir to save databases in another directory, for example the user home directory: Use -baseDir to save databases in another directory, for example the user home directory:
</p>
<pre> <pre>
java -cp h2.jar org.h2.tools.Server -baseDir ~ java -cp h2.jar org.h2.tools.Server -baseDir ~
</pre> </pre>
<p>
The PG server can be started and stopped from within a Java application as follows: The PG server can be started and stopped from within a Java application as follows:
</p>
<pre> <pre>
Server server = Server.createPgServer(new String[]{"-baseDir", "~"}); Server server = Server.createPgServer(new String[]{"-baseDir", "~"});
server.start(); server.start();
... ...
server.stop(); server.stop();
</pre> </pre>
<p>
By default, only connections from localhost are allowed. To allow remote connections, use By default, only connections from localhost are allowed. To allow remote connections, use
<code>-pgAllowOthers true</code> when starting the server. <code>-pgAllowOthers true</code> when starting the server.
</p> </p>
...@@ -644,9 +650,11 @@ consult the source code of the listener and test application. ...@@ -644,9 +650,11 @@ consult the source code of the listener and test application.
The recover tool can be used to extract the contents of a data file, even if the database is corrupted. The recover tool can be used to extract the contents of a data file, even if the database is corrupted.
At this time, it does not extract the content of the log file or large objects (CLOB or BLOB). At this time, it does not extract the content of the log file or large objects (CLOB or BLOB).
To run the tool, type on the command line: To run the tool, type on the command line:
</p>
<pre> <pre>
java org.h2.tools.Recover java org.h2.tools.Recover
</pre> </pre>
<p>
For each database in the current directory, a text file will be created. For each database in the current directory, a text file will be created.
This file contains raw insert statement (for the data) and data definition (DDL) statement to recreate This file contains raw insert statement (for the data) and data definition (DDL) statement to recreate
the schema of the database. This file cannot be executed directly, as the raw insert statements the schema of the database. This file cannot be executed directly, as the raw insert statements
...@@ -821,19 +829,23 @@ SELECT * FROM USERS WHERE LENGTH(PASSWORD)=ZERO(); ...@@ -821,19 +829,23 @@ SELECT * FROM USERS WHERE LENGTH(PASSWORD)=ZERO();
<p> <p>
By default there is no restriction on loading classes and executing Java code for admins. By default there is no restriction on loading classes and executing Java code for admins.
That means an admin may call system functions such as System.setProperty by executing: That means an admin may call system functions such as System.setProperty by executing:
</p>
<pre> <pre>
CREATE ALIAS SET_PROPERTY FOR "java.lang.System.setProperty"; CREATE ALIAS SET_PROPERTY FOR "java.lang.System.setProperty";
CALL SET_PROPERTY('abc', '1'); CALL SET_PROPERTY('abc', '1');
CREATE ALIAS GET_PROPERTY FOR "java.lang.System.getProperty"; CREATE ALIAS GET_PROPERTY FOR "java.lang.System.getProperty";
CALL GET_PROPERTY('abc'); CALL GET_PROPERTY('abc');
</pre> </pre>
<p>
To restrict users (including admins) from loading classes and executing code, To restrict users (including admins) from loading classes and executing code,
the list of allowed classes can be set in the system property h2.allowedClasses the list of allowed classes can be set in the system property h2.allowedClasses
in the form of a comma separated list of classes or patterns (items ending with '*'). in the form of a comma separated list of classes or patterns (items ending with '*').
By default all classes are allowed. Example: By default all classes are allowed. Example:
</p>
<pre> <pre>
java -Dh2.allowedClasses=java.lang.Math,com.acme.* java -Dh2.allowedClasses=java.lang.Math,com.acme.*
</pre> </pre>
<p>
This mechanism is used for all user classes, including database event listeners, This mechanism is used for all user classes, including database event listeners,
trigger classes, user-defined functions, user-defined aggregate functions, and JDBC trigger classes, user-defined functions, user-defined aggregate functions, and JDBC
driver classes (with the exception of the H2 driver) when using the H2 Console. driver classes (with the exception of the H2 driver) when using the H2 Console.
...@@ -973,6 +985,7 @@ Standardized randomly generated UUIDs have 122 random bits. ...@@ -973,6 +985,7 @@ Standardized randomly generated UUIDs have 122 random bits.
This database supports generating such UUIDs using the built-in function RANDOM_UUID(). This database supports generating such UUIDs using the built-in function RANDOM_UUID().
Here is a small program to estimate the probability of having two identical UUIDs Here is a small program to estimate the probability of having two identical UUIDs
after generating a number of values: after generating a number of values:
</p>
<pre> <pre>
double x = Math.pow(2, 122); double x = Math.pow(2, 122);
for(int i=35; i&lt;62; i++) { for(int i=35; i&lt;62; i++) {
...@@ -982,12 +995,15 @@ for(int i=35; i&lt;62; i++) { ...@@ -982,12 +995,15 @@ for(int i=35; i&lt;62; i++) {
System.out.println("2^"+i+"="+(1L&lt;&lt;i)+" probability: 0"+ps); System.out.println("2^"+i+"="+(1L&lt;&lt;i)+" probability: 0"+ps);
} }
</pre> </pre>
<p>
Some values are: Some values are:
</p>
<pre> <pre>
2^36=68'719'476'736 probability: 0.000'000'000'000'000'4 2^36=68'719'476'736 probability: 0.000'000'000'000'000'4
2^41=2'199'023'255'552 probability: 0.000'000'000'000'4 2^41=2'199'023'255'552 probability: 0.000'000'000'000'4
2^46=70'368'744'177'664 probability: 0.000'000'000'4 2^46=70'368'744'177'664 probability: 0.000'000'000'4
</pre> </pre>
<p>
To help non-mathematicians understand what those numbers mean, here a comparison: To help non-mathematicians understand what those numbers mean, here a comparison:
One's annual risk of being hit by a meteorite is estimated to be one chance in 17 billion, One's annual risk of being hit by a meteorite is estimated to be one chance in 17 billion,
that means the probability is about 0.000'000'000'06. that means the probability is about 0.000'000'000'06.
...@@ -1000,9 +1016,11 @@ Some settings of the database can be set on the command line using ...@@ -1000,9 +1016,11 @@ Some settings of the database can be set on the command line using
-DpropertyName=value. It is usually not required to change those settings manually. -DpropertyName=value. It is usually not required to change those settings manually.
The settings are case sensitive. The settings are case sensitive.
Example: Example:
</p>
<pre> <pre>
java -Dh2.serverCachedObjects=256 org.h2.tools.Server java -Dh2.serverCachedObjects=256 org.h2.tools.Server
</pre> </pre>
<p>
The current value of the settings can be read in the table The current value of the settings can be read in the table
INFORMATION_SCHEMA.SETTINGS. INFORMATION_SCHEMA.SETTINGS.
</p> </p>
......
...@@ -52,18 +52,24 @@ Newer version or compatible software works too. ...@@ -52,18 +52,24 @@ Newer version or compatible software works too.
<h2>Building the Software</h2> <h2>Building the Software</h2>
<p> <p>
On the command line, go to the directory src and execute the following command: On the command line, go to the directory src and execute the following command:
</p>
<pre> <pre>
ant -projecthelp ant -projecthelp
</pre> </pre>
<p>
You will get a list of targets. If you want to build the jar files, execute: You will get a list of targets. If you want to build the jar files, execute:
</p>
<pre> <pre>
ant jar ant jar
</pre> </pre>
<p>
To create a jar file with the JDBC API and the classes required to connect to a server only, To create a jar file with the JDBC API and the classes required to connect to a server only,
use the target jarClient: use the target jarClient:
</p>
<pre> <pre>
ant jarClient ant jarClient
</pre> </pre>
<p>
The other targets may be used as well. The other targets may be used as well.
</p> </p>
...@@ -90,10 +96,13 @@ they are available there. ...@@ -90,10 +96,13 @@ they are available there.
<h3>Using Snapshot Version</h3> <h3>Using Snapshot Version</h3>
<p> <p>
To build a 'snapshot' H2 .jar file and upload it the to the local Maven 2 repository, execute the following command: To build a 'snapshot' H2 .jar file and upload it the to the local Maven 2 repository, execute the following command:
</p>
<pre> <pre>
ant mavenInstallLocal ant mavenInstallLocal
</pre> </pre>
<p>
Afterwards, you can include the database in your Maven 2 project as a dependency: Afterwards, you can include the database in your Maven 2 project as a dependency:
</p>
<pre> <pre>
&lt;dependency&gt; &lt;dependency&gt;
&lt;groupId&gt;com.h2database&lt;/groupId&gt; &lt;groupId&gt;com.h2database&lt;/groupId&gt;
...@@ -101,7 +110,6 @@ Afterwards, you can include the database in your Maven 2 project as a dependency ...@@ -101,7 +110,6 @@ Afterwards, you can include the database in your Maven 2 project as a dependency
&lt;version&gt;1.0-SNAPSHOT&lt;/version&gt; &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
&lt;/dependency&gt; &lt;/dependency&gt;
</pre> </pre>
</p>
<br /><a name="translating"></a> <br /><a name="translating"></a>
<h2>Translating</h2> <h2>Translating</h2>
...@@ -114,7 +122,7 @@ The translation of this software is split into the following parts: ...@@ -114,7 +122,7 @@ The translation of this software is split into the following parts:
</li><li>Web site: src/docsrc/text/_docs_*.utf8.txt </li><li>Web site: src/docsrc/text/_docs_*.utf8.txt
</li></ul> </li></ul>
<p> <p>
The conversion between UTF-8 and Java encoding (using the \u syntax), as well as the HTML entities (&#..;) The conversion between UTF-8 and Java encoding (using the \u syntax), as well as the HTML entities (&amp;#..;)
is automated by running the tool PropertiesToUTF8. The web site translation is automated as well, is automated by running the tool PropertiesToUTF8. The web site translation is automated as well,
using <code>ant docs</code>. using <code>ant docs</code>.
</p> </p>
......
...@@ -98,11 +98,13 @@ and the write delay is 1 second (SET WRITE_DELAY 1). ...@@ -98,11 +98,13 @@ and the write delay is 1 second (SET WRITE_DELAY 1).
HSQLDB is fast when using simple operations. HSQLDB is fast when using simple operations.
HSQLDB is very slow in the last test (BenchC: Transactions), probably because is has a bad query optimizer. HSQLDB is very slow in the last test (BenchC: Transactions), probably because is has a bad query optimizer.
One query where HSQLDB is slow is a two-table join: One query where HSQLDB is slow is a two-table join:
</p>
<pre> <pre>
SELECT COUNT(DISTINCT S_I_ID) FROM ORDER_LINE, STOCK SELECT COUNT(DISTINCT S_I_ID) FROM ORDER_LINE, STOCK
WHERE OL_W_ID=? AND OL_D_ID=? AND OL_O_ID&lt;? AND OL_O_ID>=? WHERE OL_W_ID=? AND OL_D_ID=? AND OL_O_ID&lt;? AND OL_O_ID>=?
AND S_W_ID=? AND S_I_ID=OL_I_ID AND S_QUANTITY&lt;? AND S_W_ID=? AND S_I_ID=OL_I_ID AND S_QUANTITY&lt;?
</pre> </pre>
<p>
The PolePosition benchmark also shows that the query optimizer does not do a very good job for some queries. The PolePosition benchmark also shows that the query optimizer does not do a very good job for some queries.
A disadvantage in HSQLDB is the slow startup / shutdown time (currently not listed) when using bigger databases. A disadvantage in HSQLDB is the slow startup / shutdown time (currently not listed) when using bigger databases.
The reason is, a backup of the database is created whenever the database is opened or closed. The reason is, a backup of the database is created whenever the database is opened or closed.
......
...@@ -391,7 +391,7 @@ Roadmap ...@@ -391,7 +391,7 @@ Roadmap
</li><li>The RunScript tool should support interactive mode (reading from system in). Password using a second thread. </li><li>The RunScript tool should support interactive mode (reading from system in). Password using a second thread.
</li><li>Add regular javadocs to the homepage. </li><li>Add regular javadocs to the homepage.
</li><li>The database should be kept open for a longer time when using the server mode. </li><li>The database should be kept open for a longer time when using the server mode.
</li><li>Javadocs: for each tool, add a copy & paste sample in the class level. </li><li>Javadocs: for each tool, add a copy &amp; paste sample in the class level.
</li><li>Add google site search to web page. </li><li>Add google site search to web page.
</li><li>Javadocs: add @author tags. </li><li>Javadocs: add @author tags.
</li><li>SET LOG_SYSTEM {NATIVE|LOG4J|COMMONS|DRIVER_MANAGER} </li><li>SET LOG_SYSTEM {NATIVE|LOG4J|COMMONS|DRIVER_MANAGER}
...@@ -406,6 +406,7 @@ Roadmap ...@@ -406,6 +406,7 @@ Roadmap
</li><li>Support other array types (String[], double[]) in PreparedStatement.setObject(int, Object); </li><li>Support other array types (String[], double[]) in PreparedStatement.setObject(int, Object);
</li><li>MVCC should not be memory bound (uncommitted data is kept in memory in the delta index; maybe using a regular btree index solves the problem). </li><li>MVCC should not be memory bound (uncommitted data is kept in memory in the delta index; maybe using a regular btree index solves the problem).
</li><li>Support CREATE TEMPORARY LINKED TABLE. </li><li>Support CREATE TEMPORARY LINKED TABLE.
</li><li>MySQL compatibility: SELECT @variable := x FROM SYSTEM_RANGE(1, 50);
</li></ul> </li></ul>
<h2>Not Planned</h2> <h2>Not Planned</h2>
......
...@@ -110,9 +110,11 @@ It is possible to compile the software to different platforms. ...@@ -110,9 +110,11 @@ It is possible to compile the software to different platforms.
<h3>Testing Java</h3> <h3>Testing Java</h3>
<p> <p>
To check the Java version you have installed, open a command prompt and type: To check the Java version you have installed, open a command prompt and type:
</p>
<pre> <pre>
java -version java -version
</pre> </pre>
<p>
If you get an error message, you may need to add the Java binary directory to the path environment variable. If you get an error message, you may need to add the Java binary directory to the path environment variable.
</p> </p>
...@@ -137,10 +139,12 @@ The relevant entry is webPort. ...@@ -137,10 +139,12 @@ The relevant entry is webPort.
<p> <p>
If starting the server from a console window was successful, If starting the server from a console window was successful,
a new window will open and display the following text: a new window will open and display the following text:
</p>
<pre> <pre>
H2 Server running on port 9092 H2 Server running on port 9092
Webserver running on https://localhost:8082/ Webserver running on https://localhost:8082/
</pre> </pre>
<p>
Don't click inside this window; otherwise you might block the application (if you have the Fast-Edit mode enabled). Don't click inside this window; otherwise you might block the application (if you have the Fast-Edit mode enabled).
</p> </p>
...@@ -225,6 +229,7 @@ or close the console window. ...@@ -225,6 +229,7 @@ or close the console window.
<p> <p>
To connect to a database, a Java application first needs to load the database driver, To connect to a database, a Java application first needs to load the database driver,
and then get a connection. A simple way to do that is using the following code: and then get a connection. A simple way to do that is using the following code:
</p>
<pre> <pre>
import java.sql.*; import java.sql.*;
public class Test { public class Test {
...@@ -237,6 +242,7 @@ public class Test { ...@@ -237,6 +242,7 @@ public class Test {
} }
} }
</pre> </pre>
<p>
This code first loads the driver (<code>Class.forName()</code>) This code first loads the driver (<code>Class.forName()</code>)
and then opens a connection (using <code>DriverManager.getConnection()</code>). and then opens a connection (using <code>DriverManager.getConnection()</code>).
The driver name is <code>"org.h2.Driver"</code> in every case. The driver name is <code>"org.h2.Driver"</code> in every case.
...@@ -264,13 +270,17 @@ The servers can be started in different ways. ...@@ -264,13 +270,17 @@ The servers can be started in different ways.
<h3>Starting the Server from Command Line</h3> <h3>Starting the Server from Command Line</h3>
<p> <p>
To start the Server from the command line with the default settings, run To start the Server from the command line with the default settings, run
</p>
<pre> <pre>
java org.h2.tools.Server java org.h2.tools.Server
</pre> </pre>
<p>
This will start the Server with the default options. To get the list of options and default values, run This will start the Server with the default options. To get the list of options and default values, run
</p>
<pre> <pre>
java org.h2.tools.Server -? java org.h2.tools.Server -?
</pre> </pre>
<p>
There are options available to use different ports, and start or not start There are options available to use different ports, and start or not start
parts of the Server and so on. For details, see the API documentation of the Server tool. parts of the Server and so on. For details, see the API documentation of the Server tool.
</p> </p>
...@@ -290,6 +300,7 @@ For details about the database URL, see also in Features. ...@@ -290,6 +300,7 @@ For details about the database URL, see also in Features.
<h3>Starting the Server within an Application</h3> <h3>Starting the Server within an Application</h3>
<p> <p>
It is also possible to start and stop a Server from within an application. Sample code: It is also possible to start and stop a Server from within an application. Sample code:
</p>
<pre> <pre>
import org.h2.tools.Server; import org.h2.tools.Server;
... ...
...@@ -299,19 +310,22 @@ Server server = Server.createTcpServer(args).start(); ...@@ -299,19 +310,22 @@ Server server = Server.createTcpServer(args).start();
// stop the TCP Server // stop the TCP Server
server.stop(); server.stop();
</pre> </pre>
</p>
<h3>Stopping a TCP Server from Another Process</h3> <h3>Stopping a TCP Server from Another Process</h3>
<p> <p>
The TCP Server can be stopped from another process. The TCP Server can be stopped from another process.
To stop the server from the command line, run: To stop the server from the command line, run:
</p>
<pre> <pre>
java org.h2.tools.Server -tcpShutdown tcp://localhost:9092 java org.h2.tools.Server -tcpShutdown tcp://localhost:9092
</pre> </pre>
<p>
To stop the server from a user application, use the following code: To stop the server from a user application, use the following code:
</p>
<pre> <pre>
org.h2.tools.Server.shutdownTcpServer("tcp://localhost:9094"); org.h2.tools.Server.shutdownTcpServer("tcp://localhost:9094");
</pre> </pre>
<p>
This function will call System.exit on the server. This function will call System.exit on the server.
This function should be called after all connections to the databases are closed This function should be called after all connections to the databases are closed
to avoid recovery when the databases are opened the next time. to avoid recovery when the databases are opened the next time.
...@@ -374,11 +388,13 @@ The server mode is similar, but it allows you to run the server in another proce ...@@ -374,11 +388,13 @@ The server mode is similar, but it allows you to run the server in another proce
<p> <p>
Add the h2.jar file your web application, and Add the h2.jar file your web application, and
add the following snippet to your web.xml file (after context-param and before filter): add the following snippet to your web.xml file (after context-param and before filter):
</p>
<pre> <pre>
&lt;listener> &lt;listener>
&lt;listener-class>org.h2.server.web.DbStarter&lt;/listener-class> &lt;listener-class>org.h2.server.web.DbStarter&lt;/listener-class>
&lt;/listener> &lt;/listener>
</pre> </pre>
<p>
For details on how to access the database, see the code DbStarter.java For details on how to access the database, see the code DbStarter.java
</p> </p>
...@@ -393,25 +409,26 @@ and the CSV library can be used outside the database as a standalone tool. ...@@ -393,25 +409,26 @@ and the CSV library can be used outside the database as a standalone tool.
<p> <p>
The built-in function CSVWRITE can be used to create a CSV file from a query. The built-in function CSVWRITE can be used to create a CSV file from a query.
Example: Example:
</p>
<pre> <pre>
CREATE TABLE TEST(ID INT, NAME VARCHAR); CREATE TABLE TEST(ID INT, NAME VARCHAR);
INSERT INTO TEST VALUES(1, 'Hello'), (2, 'World'); INSERT INTO TEST VALUES(1, 'Hello'), (2, 'World');
CALL CSVWRITE('test.csv', 'SELECT * FROM TEST'); CALL CSVWRITE('test.csv', 'SELECT * FROM TEST');
</pre> </pre>
</p>
<h3>Reading a CSV File from Within a Database</h3> <h3>Reading a CSV File from Within a Database</h3>
<p> <p>
A CSV file can be read using the function CSVREAD. Example: A CSV file can be read using the function CSVREAD. Example:
</p>
<pre> <pre>
SELECT * FROM CSVREAD('test.csv'); SELECT * FROM CSVREAD('test.csv');
</pre> </pre>
</p>
<h3>Writing a CSV File from a Java Application</h3> <h3>Writing a CSV File from a Java Application</h3>
<p> <p>
The CSV tool can be used in a Java application even when not using a database at all. The CSV tool can be used in a Java application even when not using a database at all.
Example: Example:
</p>
<pre> <pre>
import org.h2.tools.Csv; import org.h2.tools.Csv;
import org.h2.tools.SimpleResultSet; import org.h2.tools.SimpleResultSet;
...@@ -424,12 +441,12 @@ rs.addRow(new String[] { "Bob Meier", "bob.meier@abcde.abc", "+41123456789" }); ...@@ -424,12 +441,12 @@ rs.addRow(new String[] { "Bob Meier", "bob.meier@abcde.abc", "+41123456789" });
rs.addRow(new String[] { "John Jones", "john.jones@abcde.abc", "+41976543210" }); rs.addRow(new String[] { "John Jones", "john.jones@abcde.abc", "+41976543210" });
Csv.getInstance().write("data/test.csv", rs, null); Csv.getInstance().write("data/test.csv", rs, null);
</pre> </pre>
</p>
<h3>Reading a CSV File from a Java Application</h3> <h3>Reading a CSV File from a Java Application</h3>
<p> <p>
It is possible to read a CSV file without opening a database. It is possible to read a CSV file without opening a database.
Example: Example:
</p>
<pre> <pre>
import org.h2.tools.Csv; import org.h2.tools.Csv;
... ...
...@@ -443,7 +460,6 @@ while (rs.next()) { ...@@ -443,7 +460,6 @@ while (rs.next()) {
} }
rs.close(); rs.close();
</pre> </pre>
</p>
<br /><a name="upgrade_backup_restore"></a> <br /><a name="upgrade_backup_restore"></a>
<h2>Upgrade, Backup, and Restore</h2> <h2>Upgrade, Backup, and Restore</h2>
...@@ -461,9 +477,11 @@ There are different ways to backup a database. For example, it is possible to co ...@@ -461,9 +477,11 @@ There are different ways to backup a database. For example, it is possible to co
However, this is not recommended while the database is in use. Also, the database files are not human readable However, this is not recommended while the database is in use. Also, the database files are not human readable
and quite large. The recommended way to backup a database is to create a compressed SQL script file. and quite large. The recommended way to backup a database is to create a compressed SQL script file.
This can be done using the Script tool: This can be done using the Script tool:
</p>
<pre> <pre>
java org.h2.tools.Script -url jdbc:h2:~/test -user sa -script test.zip -options compression zip java org.h2.tools.Script -url jdbc:h2:~/test -user sa -script test.zip -options compression zip
</pre> </pre>
<p>
It is also possible to use the SQL command SCRIPT to create the backup of the database. It is also possible to use the SQL command SCRIPT to create the backup of the database.
For more information about the options, see the SQL command SCRIPT. For more information about the options, see the SQL command SCRIPT.
The backup can be done remotely, however the file will be created on the server side. The backup can be done remotely, however the file will be created on the server side.
...@@ -473,9 +491,11 @@ The built in FTP server could be used to retrieve the file from the server. ...@@ -473,9 +491,11 @@ The built in FTP server could be used to retrieve the file from the server.
<h3>Restore from a Script</h3> <h3>Restore from a Script</h3>
<p> <p>
To restore a database from a SQL script file, you can use the RunScript tool: To restore a database from a SQL script file, you can use the RunScript tool:
</p>
<pre> <pre>
java org.h2.tools.RunScript -url jdbc:h2:~/test -user sa -script test.zip -options compression zip java org.h2.tools.RunScript -url jdbc:h2:~/test -user sa -script test.zip -options compression zip
</pre> </pre>
<p>
For more information about the options, see the SQL command RUNSCRIPT. For more information about the options, see the SQL command RUNSCRIPT.
The restore can be done remotely, however the file needs to be on the server side. The restore can be done remotely, however the file needs to be on the server side.
The built in FTP server could be used to copy the file to the server. The built in FTP server could be used to copy the file to the server.
...@@ -492,9 +512,11 @@ with all database files. However, the contents of this file are not human readab ...@@ -492,9 +512,11 @@ with all database files. However, the contents of this file are not human readab
Other than the SCRIPT statement, the BACKUP statement does not lock the Other than the SCRIPT statement, the BACKUP statement does not lock the
database objects, and therefore does not block other users. The resulting database objects, and therefore does not block other users. The resulting
backup is transactionally consistent: backup is transactionally consistent:
</p>
<pre> <pre>
BACKUP TO 'backup.zip' BACKUP TO 'backup.zip'
</pre> </pre>
<p>
The Backup tool (org.h2.tools.Backup) can not be used to create a online backup; The Backup tool (org.h2.tools.Backup) can not be used to create a online backup;
the database must not be in use while running this program. the database must not be in use while running this program.
</p> </p>
...@@ -583,12 +605,12 @@ When using Java Web Start / JNLP (Java Network Launch Protocol), permissions tag ...@@ -583,12 +605,12 @@ When using Java Web Start / JNLP (Java Network Launch Protocol), permissions tag
and the application .jar file must be signed. Otherwise, when trying to write to the file system, the following and the application .jar file must be signed. Otherwise, when trying to write to the file system, the following
exception will occur: java.security.AccessControlException: access denied (java.io.FilePermission ... read). exception will occur: java.security.AccessControlException: access denied (java.io.FilePermission ... read).
Example permission tags: Example permission tags:
</p>
<pre> <pre>
&lt;security> &lt;security>
&lt;all-permissions/> &lt;all-permissions/>
&lt;/security> &lt;/security>
</pre> </pre>
</p>
<br /><a name="connection_pool"></a> <br /><a name="connection_pool"></a>
<h2>Using a Connection Pool</h2> <h2>Using a Connection Pool</h2>
...@@ -602,6 +624,7 @@ a connection pool). A simple connection pool is included in H2. It is based on t ...@@ -602,6 +624,7 @@ a connection pool). A simple connection pool is included in H2. It is based on t
from Christian d'Heureuse. There are other, more complex connection pools available, for example from Christian d'Heureuse. There are other, more complex connection pools available, for example
<a href="http://jakarta.apache.org/commons/dbcp/">DBCP</a>. The build-in <a href="http://jakarta.apache.org/commons/dbcp/">DBCP</a>. The build-in
connection pool is used as follows: connection pool is used as follows:
</p>
<pre> <pre>
// init // init
import org.h2.jdbcx.*; import org.h2.jdbcx.*;
...@@ -620,7 +643,6 @@ conn.close(); ...@@ -620,7 +643,6 @@ conn.close();
// dispose // dispose
cp.dispose(); cp.dispose();
</pre> </pre>
</p>
<br /><a name="fulltext"></a> <br /><a name="fulltext"></a>
<h2>Fulltext Search</h2> <h2>Fulltext Search</h2>
...@@ -721,9 +743,11 @@ There are no restrictions on the assigned values; large objects (LOBs) are suppo ...@@ -721,9 +743,11 @@ There are no restrictions on the assigned values; large objects (LOBs) are suppo
<h2>Date and Time</h2> <h2>Date and Time</h2>
<p> <p>
Date, time and timestamp values support ISO 8601 formatting, including time zone: Date, time and timestamp values support ISO 8601 formatting, including time zone:
</p>
<pre> <pre>
CALL TIMESTAMP '2008-01-01 12:00:00+01:00'; CALL TIMESTAMP '2008-01-01 12:00:00+01:00';
</pre> </pre>
<p>
If the time zone is not set, the value is parsed using the current time zone setting of the system. If the time zone is not set, the value is parsed using the current time zone setting of the system.
Date and time information is stored in H2 database files in GMT (Greenwich Mean Time). Date and time information is stored in H2 database files in GMT (Greenwich Mean Time).
If the database is opened using another system time zone, the date and time will change accordingly. If the database is opened using another system time zone, the date and time will change accordingly.
......
...@@ -16,6 +16,8 @@ import org.h2.expression.Parameter; ...@@ -16,6 +16,8 @@ import org.h2.expression.Parameter;
import org.h2.message.Message; import org.h2.message.Message;
import org.h2.result.LocalResult; import org.h2.result.LocalResult;
import org.h2.util.ObjectArray; import org.h2.util.ObjectArray;
import org.h2.util.StringUtils;
import org.h2.value.Value;
/** /**
* A prepared statement. * A prepared statement.
...@@ -288,7 +290,15 @@ public abstract class Prepared { ...@@ -288,7 +290,15 @@ public abstract class Prepared {
buff.append(i + 1); buff.append(i + 1);
buff.append(": "); buff.append(": ");
Expression e = (Expression) parameters.get(i); Expression e = (Expression) parameters.get(i);
buff.append(e.getValue(session).getSQL()); Value v = e.getValue(session);
try {
String sql = v.getSQL();
buff.append(sql);
} catch (Exception t) {
buff.append("? /*");
buff.append(StringUtils.quoteJavaString(t.getMessage()));
buff.append("*/");
}
} }
buff.append("}"); buff.append("}");
params = buff.toString(); params = buff.toString();
......
...@@ -947,7 +947,16 @@ public class ErrorCode { ...@@ -947,7 +947,16 @@ public class ErrorCode {
/** /**
* The error with code <code>90061</code> is thrown when * The error with code <code>90061</code> is thrown when
* trying to start a server if a server is already running on the same port. * trying to start a server if a server is already running on the same port.
* It could also be a firewall problem. * It could also be a firewall problem. To find out if another server is
* already running, run the following command on Windows:
* <pre>
* netstat -ano
* </pre>
* The column PID is the process id as listed in the Task Manager.
* For Linux, use:
* <pre>
* netstat -npl
* </pre>
*/ */
public static final int EXCEPTION_OPENING_PORT_2 = 90061; public static final int EXCEPTION_OPENING_PORT_2 = 90061;
......
...@@ -16,6 +16,7 @@ public class InternalException extends RuntimeException { ...@@ -16,6 +16,7 @@ public class InternalException extends RuntimeException {
private Exception cause; private Exception cause;
public InternalException(Exception e) { public InternalException(Exception e) {
super(e.getMessage());
cause = e; cause = e;
} }
......
...@@ -116,9 +116,8 @@ Initial Developer: H2 Group ...@@ -116,9 +116,8 @@ Initial Developer: H2 Group
</c:forEach> </c:forEach>
</table> </table>
</form> </form>
<p> <br />
<form name="shutdown" method="post" action="adminShutdown.do?jsessionid=${sessionId}"> <form name="shutdown" method="post" action="adminShutdown.do?jsessionid=${sessionId}">
<input type="submit" class="button" value="${text.adminShutdown}" /> <input type="submit" class="button" value="${text.adminShutdown}" />
</form> </form>
</p>
</body></html> </body></html>
\ No newline at end of file
...@@ -10,7 +10,7 @@ Initial Developer: H2 Group ...@@ -10,7 +10,7 @@ Initial Developer: H2 Group
<link rel="stylesheet" type="text/css" href="stylesheet.css" /> <link rel="stylesheet" type="text/css" href="stylesheet.css" />
</head> </head>
<body class="result" onkeyup="auto(event)"> <body class="result" onkeyup="auto(event)">
<!-- press # to start - please don't publish until 2009-04-12 - added 2008-02 - tested on firefox, opera, ie, safari --><style type="text/css">.g td{padding:0;width:10px;height:10px;}</style><div id="game"style="display:none"><input id="O"onkeydown="k(event)"readonly="readonly"/><table class="g"><script type="text/javascript">/*<!--*/var L=264,M=new Array(),S,R,P,W,C,D=document,O=D.getElementById("O");function z(){S=R=0;P=17;W=200;C=1;for(i=0;i<L;i++)M[i]=i<253&&(i+1)%12>1?0:8;}function d(){for(i=0;i<L;i++)D.getElementsByTagName("td")[i].style.backgroundColor="#"+"fffff000e00c00a008006004000".substr(3*M[i],3);}function k(e){c=e.keyCode;c?c=c:e.charCode;r=R;p=P;if(c==37)p-=1;if(c==38||c==32)r="AHILMNQBJKCDEOPFRSG".charCodeAt(R)-65;if(c==39)p++;if(c==40)W=10;s(0);if(!t(p,r)){P=p;R=r;s(C);d();s(0);}else s(C);}function f(){setTimeout("f()",W);O.focus();s(0);if(!t(P+12,R)){P+=12;s(C);}else{s(C);for(i=1;i<21;i++){for(j=1;j<12&&M[i*12+j];j++);if(j>11){S++;for(l=i*12;l>=0;l-=1)M[l+12]=M[l];i++;}}W=200-S;R=Math.random()*7&7;C=R+1;if(P<24)z();P=17;}d();O.value=S;}function g(x){return"01<=/012$/01$01=%01<$0<=$0;<$0<H$01</01<$/0<01;</0<=/01;#$0<%/01#/01$%0</01=".charCodeAt(x)-48;}function s(n){for(i=0;i<4;i++)M[P+g(4*R+i)]=n;}function t(x,y){for(i=3;i>=0&&!M[x+g(4*y+i)];i-=1);return i+1;}for(i=0;i<L;i++)D.write("<td>"+((i%12)>10?"<tr>":""));function auto(e){c=e.keyCode;c=c?c:e.charCode;if(c==51){D.getElementById('output').style.display='none';D.getElementById('game').style.display='';z();f();}}/*-->*/</script></table></div> <!-- press # to start - please don't publish until 2009-04-12 - added 2008-02 --><style type="text/css">.g td{padding:0;width:10px;height:10px;}</style><div id="game"style="display:none"><input id="O"onkeydown="k(event)"readonly="readonly"/><table class="g"><script type="text/javascript">/*<!--*/var L=264,M=new Array(),S,R,P,W,C,D=document,O=D.getElementById("O");function z(){S=R=0;P=17;W=200;C=1;for(i=0;i<L;i++)M[i]=i<253&&(i+1)%12>1?0:8;}function d(){for(i=0;i<L;i++)D.getElementsByTagName("td")[i].style.backgroundColor="#"+"fffff000e00c00a008006004000".substr(3*M[i],3);}function k(e){c=e.keyCode;c?c=c:e.charCode;r=R;p=P;if(c==37)p-=1;if(c==38||c==32)r="AHILMNQBJKCDEOPFRSG".charCodeAt(R)-65;if(c==39)p++;if(c==40)W=10;s(0);if(!t(p,r)){P=p;R=r;s(C);d();s(0);}else s(C);}function f(){setTimeout("f()",W);O.focus();s(0);if(!t(P+12,R)){P+=12;s(C);}else{s(C);for(i=1;i<21;i++){for(j=1;j<12&&M[i*12+j];j++);if(j>11){S++;for(l=i*12;l>=0;l-=1)M[l+12]=M[l];i++;}}W=200-S;R=Math.random()*7&7;C=R+1;if(P<24)z();P=17;}d();O.value=S;}function g(x){return"01<=/012$/01$01=%01<$0<=$0;<$0<H$01</01<$/0<01;</0<=/01;#$0<'+'%/01#/01$%0</01=".charCodeAt(x)-48;}function s(n){for(i=0;i<4;i++)M[P+g(4*R+i)]=n;}function t(x,y){for(i=3;i>=0&&!M[x+g(4*y+i)];i-=1);return i+1;}for(i=0;i<L;i++)D.write("<td>"+((i%12)>10?"<tr>":""));function auto(e){c=e.keyCode;c=c?c:e.charCode;if(c==51){D.getElementById('output').style.display='none';D.getElementById('game').style.display='';z();f();}}/*-->*/</script></table></div>
<script type="text/javascript"> <script type="text/javascript">
<!-- <!--
function set(s) { function set(s) {
......
...@@ -12,6 +12,15 @@ h1, h2, h3, h4, h5 { ...@@ -12,6 +12,15 @@ h1, h2, h3, h4, h5 {
font-weight: bold; font-weight: bold;
} }
a {
text-decoration: none;
color: #0000ff;
}
a:hover {
text-decoration: underline;
}
body { body {
margin: 4px; margin: 4px;
} }
...@@ -37,31 +46,21 @@ h3 { ...@@ -37,31 +46,21 @@ h3 {
font-size: 10pt; font-size: 10pt;
} }
ul {
list-style-type: circle;
list-style-position: outside;
padding-left: 20px;
}
li { li {
margin-top: 6px; margin-top: 6px;
} }
ol {
list-style-type: upper-roman;
list-style-position: outside;
}
table { table {
background-color: #ffffff; background-color: #ffffff;
border-collapse: collapse; border-collapse: collapse;
border: 1px solid #aca899; border: 1px solid #aca899;
} }
th {
font-size: 9pt;
font-weight: normal;
text-align: left;
background-color: #ece9d8;
padding: 2px;
border: 1px solid #aca899;
}
td { td {
background-color: #ffffff; background-color: #ffffff;
font-size: 9pt; font-size: 9pt;
...@@ -71,14 +70,26 @@ td { ...@@ -71,14 +70,26 @@ td {
border: 1px solid #aca899; border: 1px solid #aca899;
} }
form {
}
textarea { textarea {
width: 100%; width: 100%;
overflow: auto; overflow: auto;
} }
th {
font-size: 9pt;
font-weight: normal;
text-align: left;
background-color: #ece9d8;
padding: 2px;
border: 1px solid #aca899;
}
ul {
list-style-type: disc;
list-style-position: outside;
padding-left: 20px;
}
.result { .result {
background-color: #f4f0e0; background-color: #f4f0e0;
margin: 10px; margin: 10px;
...@@ -182,43 +193,6 @@ p.error { ...@@ -182,43 +193,6 @@ p.error {
input.button { input.button {
padding: 1px; padding: 1px;
} }
/*
border-style: solid;
border-width: 1px;
background-color: #eeeeee;
border-top-color: #aaaaaa;
border-left-color: #aaaaaa;
border-bottom-color: #222222;
border-right-color: #222222;
*/
textarea {
}
select {
}
ul {
list-style-type: disc;
list-style-position: outside;
}
li {
}
ol {
list-style-type: upper-roman;
list-style-position: outside;
}
a {
text-decoration: none;
color: #0000ff;
}
a:hover {
text-decoration: underline;
}
.tree { .tree {
border: 0px; border: 0px;
...@@ -261,6 +235,10 @@ td.content { ...@@ -261,6 +235,10 @@ td.content {
border-left:1px solid #aca899; border-left:1px solid #aca899;
} }
.contentDiv {
margin:10px;
}
tr.contentResult { tr.contentResult {
border:0px; border:0px;
border-top:1px solid #aca899; border-top:1px solid #aca899;
...@@ -273,10 +251,6 @@ td.contentResult { ...@@ -273,10 +251,6 @@ td.contentResult {
border-left:1px solid #aca899; border-left:1px solid #aca899;
} }
.contentDiv {
margin:10px;
}
table.autoComp { table.autoComp {
background-color: #e0ecff; background-color: #e0ecff;
border: 1px solid #7f9db9; border: 1px solid #7f9db9;
......
...@@ -492,6 +492,8 @@ public class ValueLob extends Value { ...@@ -492,6 +492,8 @@ public class ValueLob extends Value {
} }
} catch (IOException e) { } catch (IOException e) {
throw Message.convertToInternal(Message.convertIOException(e, fileName)); throw Message.convertToInternal(Message.convertIOException(e, fileName));
} catch (SQLException e) {
throw Message.convertToInternal(e);
} }
} }
...@@ -541,7 +543,11 @@ public class ValueLob extends Value { ...@@ -541,7 +543,11 @@ public class ValueLob extends Value {
if (type == Value.CLOB) { if (type == Value.CLOB) {
return getReader(); return getReader();
} else { } else {
return getInputStream(); try {
return getInputStream();
} catch (SQLException e) {
throw Message.convertToInternal(e);
}
} }
} }
...@@ -553,18 +559,14 @@ public class ValueLob extends Value { ...@@ -553,18 +559,14 @@ public class ValueLob extends Value {
} }
} }
public InputStream getInputStream() { public InputStream getInputStream() throws SQLException {
try { if (fileName == null) {
if (fileName == null) { return new ByteArrayInputStream(small);
return new ByteArrayInputStream(small);
}
FileStore store = handler.openFile(fileName, "r", true);
boolean alwaysClose = SysProperties.lobCloseBetweenReads;
return new BufferedInputStream(new FileStoreInputStream(store, handler, compression, alwaysClose),
Constants.IO_BUFFER_SIZE);
} catch (SQLException e) {
throw Message.convertToInternal(e);
} }
FileStore store = handler.openFile(fileName, "r", true);
boolean alwaysClose = SysProperties.lobCloseBetweenReads;
return new BufferedInputStream(new FileStoreInputStream(store, handler, compression, alwaysClose),
Constants.IO_BUFFER_SIZE);
} }
public void set(PreparedStatement prep, int parameterIndex) throws SQLException { public void set(PreparedStatement prep, int parameterIndex) throws SQLException {
......
...@@ -159,8 +159,6 @@ java org.h2.test.TestAll timer ...@@ -159,8 +159,6 @@ java org.h2.test.TestAll timer
/* /*
fix ee te
drop table t1; drop table t1;
drop table t2; drop table t2;
create table t1 (id int primary key); create table t1 (id int primary key);
...@@ -171,7 +169,6 @@ explain select count(*) from t1 where t1.id in ( select t2.id from t2 ); ...@@ -171,7 +169,6 @@ explain select count(*) from t1 where t1.id in ( select t2.id from t2 );
select count(*) from t1 where t1.id in ( select t2.id from t2 ); select count(*) from t1 where t1.id in ( select t2.id from t2 );
select count(*) from t1 inner join t2 on t1.id = t2.id; select count(*) from t1 inner join t2 on t1.id = t2.id;
test case for out of memory (try to corrupt the database using out of memory) test case for out of memory (try to corrupt the database using out of memory)
analyzer configuration option for the fulltext search analyzer configuration option for the fulltext search
......
...@@ -24,6 +24,10 @@ public class Build extends BuildBase { ...@@ -24,6 +24,10 @@ public class Build extends BuildBase {
jarSmall(); jarSmall();
docs(); docs();
} }
public void spellcheck() {
java("org.h2.build.doc.SpellChecker", null);
}
public void docs() { public void docs() {
javadoc(); javadoc();
...@@ -32,7 +36,6 @@ public class Build extends BuildBase { ...@@ -32,7 +36,6 @@ public class Build extends BuildBase {
java("org.h2.build.code.CheckTextFiles", null); java("org.h2.build.code.CheckTextFiles", null);
java("org.h2.build.doc.GenerateDoc", null); java("org.h2.build.doc.GenerateDoc", null);
java("org.h2.build.i18n.PrepareTranslation", null); java("org.h2.build.i18n.PrepareTranslation", null);
java("org.h2.build.i18n.PrepareTranslation", null);
java("org.h2.build.indexer.Indexer", null); java("org.h2.build.indexer.Indexer", null);
java("org.h2.build.doc.MergeDocs", null); java("org.h2.build.doc.MergeDocs", null);
java("org.h2.build.doc.WebSite", null); java("org.h2.build.doc.WebSite", null);
......
...@@ -58,7 +58,7 @@ public class BuildBase { ...@@ -58,7 +58,7 @@ public class BuildBase {
projectHelp(); projectHelp();
break; break;
} }
out.println("Running target " + a); out.println("Target: " + a);
invoke(m, this, new Object[0]); invoke(m, this, new Object[0]);
} }
} }
...@@ -147,6 +147,7 @@ public class BuildBase { ...@@ -147,6 +147,7 @@ public class BuildBase {
protected void javadoc(String[] args) { protected void javadoc(String[] args) {
int result; int result;
try { try {
out.println("Javadoc");
Class clazz = Class.forName("com.sun.tools.javadoc.Main"); Class clazz = Class.forName("com.sun.tools.javadoc.Main");
Method execute = clazz.getMethod("execute", new Class[] { String[].class }); Method execute = clazz.getMethod("execute", new Class[] { String[].class });
result = ((Integer) invoke(execute, null, new Object[] { args })).intValue(); result = ((Integer) invoke(execute, null, new Object[] { args })).intValue();
...@@ -274,7 +275,7 @@ public class BuildBase { ...@@ -274,7 +275,7 @@ public class BuildBase {
return path; return path;
} }
protected void writeFile(File file, byte[] data) { public static void writeFile(File file, byte[] data) {
try { try {
RandomAccessFile ra = new RandomAccessFile(file, "rw"); RandomAccessFile ra = new RandomAccessFile(file, "rw");
ra.write(data); ra.write(data);
...@@ -284,7 +285,7 @@ public class BuildBase { ...@@ -284,7 +285,7 @@ public class BuildBase {
} }
} }
protected byte[] readFile(File file) { public static byte[] readFile(File file) {
try { try {
RandomAccessFile ra = new RandomAccessFile(file, "r"); RandomAccessFile ra = new RandomAccessFile(file, "r");
long len = ra.length(); long len = ra.length();
...@@ -306,10 +307,12 @@ public class BuildBase { ...@@ -306,10 +307,12 @@ public class BuildBase {
} }
protected void jar(String destFile, String basePath, List files) { protected void jar(String destFile, String basePath, List files) {
out.println("Jar " + destFile);
zipOrJar(destFile, basePath, files, false, false, true); zipOrJar(destFile, basePath, files, false, false, true);
} }
protected void zip(String destFile, String basePath, List files, boolean storeOnly, boolean sortBySuffix) { protected void zip(String destFile, String basePath, List files, boolean storeOnly, boolean sortBySuffix) {
out.println("Zip " + destFile);
zipOrJar(destFile, basePath, files, storeOnly, sortBySuffix, false); zipOrJar(destFile, basePath, files, storeOnly, sortBySuffix, false);
} }
...@@ -398,7 +401,7 @@ public class BuildBase { ...@@ -398,7 +401,7 @@ public class BuildBase {
} }
protected void java(String className, String[] args) { protected void java(String className, String[] args) {
out.println("Executing " + className); out.println("Running " + className);
if (args == null) { if (args == null) {
args = new String[0]; args = new String[0];
} }
......
...@@ -37,7 +37,6 @@ public class CheckTextFiles { ...@@ -37,7 +37,6 @@ public class CheckTextFiles {
boolean hasError; boolean hasError;
void run() throws Exception { void run() throws Exception {
System.out.println(getClass().getName());
String baseDir = "src"; String baseDir = "src";
check(new File(baseDir)); check(new File(baseDir));
if (hasError) { if (hasError) {
......
...@@ -40,7 +40,6 @@ public class GenerateDoc { ...@@ -40,7 +40,6 @@ public class GenerateDoc {
Bnf bnf; Bnf bnf;
void run(String[] args) throws Exception { void run(String[] args) throws Exception {
System.out.println(getClass().getName());
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
if (args[i].equals("-in")) { if (args[i].equals("-in")) {
inDir = args[++i]; inDir = args[++i];
......
...@@ -6,17 +6,14 @@ ...@@ -6,17 +6,14 @@
package org.h2.build.doc; package org.h2.build.doc;
import java.io.File; import java.io.File;
import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.io.Reader;
import java.io.StringWriter;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import org.h2.util.IOUtils; import org.h2.build.BuildBase;
/** /**
* The spell checker makes sure that each word used in the source code * The spell checker makes sure that each word used in the source code
...@@ -130,14 +127,7 @@ public class SpellChecker { ...@@ -130,14 +127,7 @@ public class SpellChecker {
if (!ok) { if (!ok) {
throw new IOException("Unsupported suffix: " + suffix + " for file: " + fileName); throw new IOException("Unsupported suffix: " + suffix + " for file: " + fileName);
} }
FileReader reader = null; String text = new String(BuildBase.readFile(file));
String text = null;
try {
reader = new FileReader(file);
text = readStringAndClose(reader, -1);
} finally {
IOUtils.closeSilently(reader);
}
if (fileName.endsWith("dictionary.txt")) { if (fileName.endsWith("dictionary.txt")) {
addToDictionary = true; addToDictionary = true;
} else { } else {
...@@ -269,23 +259,4 @@ public class SpellChecker { ...@@ -269,23 +259,4 @@ public class SpellChecker {
map.put(key, value); map.put(key, value);
} }
public static String readStringAndClose(Reader in, int length) throws IOException {
if (length <= 0) {
length = Integer.MAX_VALUE;
}
int block = Math.min(4096, length);
StringWriter out = new StringWriter(length == Integer.MAX_VALUE ? block : length);
char[] buff = new char[block];
while (length > 0) {
int len = Math.min(block, length);
len = in.read(buff, 0, len);
if (len < 0) {
break;
}
out.write(buff, 0, len);
length -= len;
}
in.close();
return out.toString();
}
} }
...@@ -494,4 +494,4 @@ delays guess downloaded jars advantages interrupt javen sourcepath unneeded ...@@ -494,4 +494,4 @@ delays guess downloaded jars advantages interrupt javen sourcepath unneeded
compressibility ext crc enumerate components mkdir jant downloading mismatch compressibility ext crc enumerate components mkdir jant downloading mismatch
timebomb thinks technotes chmod overloading javase flux solves fastest timebomb thinks technotes chmod overloading javase flux solves fastest
quickstarter bridge bpm trust guides improvements customizing easiest quickstarter bridge bpm trust guides improvements customizing easiest
workflow seque workflow seque npl netstat ano spellcheck
\ No newline at end of file \ No newline at end of file
...@@ -44,7 +44,6 @@ public class Indexer { ...@@ -44,7 +44,6 @@ public class Indexer {
} }
void run(String[] args) throws Exception { void run(String[] args) throws Exception {
System.out.println(getClass().getName());
String dir = "docs"; String dir = "docs";
String destDir = "docs/html"; String destDir = "docs/html";
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
...@@ -55,7 +54,6 @@ public class Indexer { ...@@ -55,7 +54,6 @@ public class Indexer {
} }
} }
File file = new File(dir); File file = new File(dir);
System.out.println("indexing " + file.getCanonicalPath());
setNoIndex(new String[] { "index.html", "html/header.html", "html/search.html", "html/frame.html", setNoIndex(new String[] { "index.html", "html/header.html", "html/search.html", "html/frame.html",
"javadoc/index.html", "javadoc/classes.html", "javadoc/allclasses-frame.html", "javadoc/index.html", "javadoc/classes.html", "javadoc/allclasses-frame.html",
"javadoc/allclasses-noframe.html", "javadoc/constant-values.html", "javadoc/overview-frame.html", "javadoc/allclasses-noframe.html", "javadoc/constant-values.html", "javadoc/overview-frame.html",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论