提交 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.
</p>
<p>
To use the MVCC feature, append MVCC=TRUE to the database URL:
</p>
<pre>
jdbc:h2:~/test;MVCC=TRUE
</pre>
</p>
<p>
The MVCC feature is not fully tested yet.
</p>
......@@ -406,22 +406,28 @@ The Windows version of the PostgreSQL ODBC driver is available at
<h3>Starting the Server</h3>
<p>
After installing the ODBC driver, start the H2 Server using the command line:
</p>
<pre>
java -cp h2.jar org.h2.tools.Server
</pre>
<p>
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.
Use -baseDir to save databases in another directory, for example the user home directory:
</p>
<pre>
java -cp h2.jar org.h2.tools.Server -baseDir ~
</pre>
<p>
The PG server can be started and stopped from within a Java application as follows:
</p>
<pre>
Server server = Server.createPgServer(new String[]{"-baseDir", "~"});
server.start();
...
server.stop();
</pre>
<p>
By default, only connections from localhost are allowed. To allow remote connections, use
<code>-pgAllowOthers true</code> when starting the server.
</p>
......@@ -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.
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:
</p>
<pre>
java org.h2.tools.Recover
</pre>
<p>
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
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();
<p>
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:
</p>
<pre>
CREATE ALIAS SET_PROPERTY FOR "java.lang.System.setProperty";
CALL SET_PROPERTY('abc', '1');
CREATE ALIAS GET_PROPERTY FOR "java.lang.System.getProperty";
CALL GET_PROPERTY('abc');
</pre>
<p>
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
in the form of a comma separated list of classes or patterns (items ending with '*').
By default all classes are allowed. Example:
</p>
<pre>
java -Dh2.allowedClasses=java.lang.Math,com.acme.*
</pre>
<p>
This mechanism is used for all user classes, including database event listeners,
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.
......@@ -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().
Here is a small program to estimate the probability of having two identical UUIDs
after generating a number of values:
</p>
<pre>
double x = Math.pow(2, 122);
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);
}
</pre>
<p>
Some values are:
</p>
<pre>
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^46=70'368'744'177'664 probability: 0.000'000'000'4
</pre>
<p>
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,
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
-DpropertyName=value. It is usually not required to change those settings manually.
The settings are case sensitive.
Example:
</p>
<pre>
java -Dh2.serverCachedObjects=256 org.h2.tools.Server
</pre>
<p>
The current value of the settings can be read in the table
INFORMATION_SCHEMA.SETTINGS.
</p>
......
......@@ -52,18 +52,24 @@ Newer version or compatible software works too.
<h2>Building the Software</h2>
<p>
On the command line, go to the directory src and execute the following command:
</p>
<pre>
ant -projecthelp
</pre>
<p>
You will get a list of targets. If you want to build the jar files, execute:
</p>
<pre>
ant jar
</pre>
<p>
To create a jar file with the JDBC API and the classes required to connect to a server only,
use the target jarClient:
</p>
<pre>
ant jarClient
</pre>
<p>
The other targets may be used as well.
</p>
......@@ -90,10 +96,13 @@ they are available there.
<h3>Using Snapshot Version</h3>
<p>
To build a 'snapshot' H2 .jar file and upload it the to the local Maven 2 repository, execute the following command:
</p>
<pre>
ant mavenInstallLocal
</pre>
<p>
Afterwards, you can include the database in your Maven 2 project as a dependency:
</p>
<pre>
&lt;dependency&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
&lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
&lt;/dependency&gt;
</pre>
</p>
<br /><a name="translating"></a>
<h2>Translating</h2>
......@@ -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></ul>
<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,
using <code>ant docs</code>.
</p>
......
......@@ -98,11 +98,13 @@ and the write delay is 1 second (SET WRITE_DELAY 1).
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.
One query where HSQLDB is slow is a two-table join:
</p>
<pre>
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>=?
AND S_W_ID=? AND S_I_ID=OL_I_ID AND S_QUANTITY&lt;?
</pre>
<p>
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.
The reason is, a backup of the database is created whenever the database is opened or closed.
......
......@@ -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>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>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>Javadocs: add @author tags.
</li><li>SET LOG_SYSTEM {NATIVE|LOG4J|COMMONS|DRIVER_MANAGER}
......@@ -406,6 +406,7 @@ Roadmap
</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>Support CREATE TEMPORARY LINKED TABLE.
</li><li>MySQL compatibility: SELECT @variable := x FROM SYSTEM_RANGE(1, 50);
</li></ul>
<h2>Not Planned</h2>
......
......@@ -110,9 +110,11 @@ It is possible to compile the software to different platforms.
<h3>Testing Java</h3>
<p>
To check the Java version you have installed, open a command prompt and type:
</p>
<pre>
java -version
</pre>
<p>
If you get an error message, you may need to add the Java binary directory to the path environment variable.
</p>
......@@ -137,10 +139,12 @@ The relevant entry is webPort.
<p>
If starting the server from a console window was successful,
a new window will open and display the following text:
</p>
<pre>
H2 Server running on port 9092
Webserver running on https://localhost:8082/
</pre>
<p>
Don't click inside this window; otherwise you might block the application (if you have the Fast-Edit mode enabled).
</p>
......@@ -225,6 +229,7 @@ or close the console window.
<p>
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:
</p>
<pre>
import java.sql.*;
public class Test {
......@@ -237,6 +242,7 @@ public class Test {
}
}
</pre>
<p>
This code first loads the driver (<code>Class.forName()</code>)
and then opens a connection (using <code>DriverManager.getConnection()</code>).
The driver name is <code>"org.h2.Driver"</code> in every case.
......@@ -264,13 +270,17 @@ The servers can be started in different ways.
<h3>Starting the Server from Command Line</h3>
<p>
To start the Server from the command line with the default settings, run
</p>
<pre>
java org.h2.tools.Server
</pre>
<p>
This will start the Server with the default options. To get the list of options and default values, run
</p>
<pre>
java org.h2.tools.Server -?
</pre>
<p>
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.
</p>
......@@ -290,6 +300,7 @@ For details about the database URL, see also in Features.
<h3>Starting the Server within an Application</h3>
<p>
It is also possible to start and stop a Server from within an application. Sample code:
</p>
<pre>
import org.h2.tools.Server;
...
......@@ -299,19 +310,22 @@ Server server = Server.createTcpServer(args).start();
// stop the TCP Server
server.stop();
</pre>
</p>
<h3>Stopping a TCP Server from Another Process</h3>
<p>
The TCP Server can be stopped from another process.
To stop the server from the command line, run:
</p>
<pre>
java org.h2.tools.Server -tcpShutdown tcp://localhost:9092
</pre>
<p>
To stop the server from a user application, use the following code:
</p>
<pre>
org.h2.tools.Server.shutdownTcpServer("tcp://localhost:9094");
</pre>
<p>
This function will call System.exit on the server.
This function should be called after all connections to the databases are closed
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
<p>
Add the h2.jar file your web application, and
add the following snippet to your web.xml file (after context-param and before filter):
</p>
<pre>
&lt;listener>
&lt;listener-class>org.h2.server.web.DbStarter&lt;/listener-class>
&lt;/listener>
</pre>
<p>
For details on how to access the database, see the code DbStarter.java
</p>
......@@ -393,25 +409,26 @@ and the CSV library can be used outside the database as a standalone tool.
<p>
The built-in function CSVWRITE can be used to create a CSV file from a query.
Example:
</p>
<pre>
CREATE TABLE TEST(ID INT, NAME VARCHAR);
INSERT INTO TEST VALUES(1, 'Hello'), (2, 'World');
CALL CSVWRITE('test.csv', 'SELECT * FROM TEST');
</pre>
</p>
<h3>Reading a CSV File from Within a Database</h3>
<p>
A CSV file can be read using the function CSVREAD. Example:
</p>
<pre>
SELECT * FROM CSVREAD('test.csv');
</pre>
</p>
<h3>Writing a CSV File from a Java Application</h3>
<p>
The CSV tool can be used in a Java application even when not using a database at all.
Example:
</p>
<pre>
import org.h2.tools.Csv;
import org.h2.tools.SimpleResultSet;
......@@ -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" });
Csv.getInstance().write("data/test.csv", rs, null);
</pre>
</p>
<h3>Reading a CSV File from a Java Application</h3>
<p>
It is possible to read a CSV file without opening a database.
Example:
</p>
<pre>
import org.h2.tools.Csv;
...
......@@ -443,7 +460,6 @@ while (rs.next()) {
}
rs.close();
</pre>
</p>
<br /><a name="upgrade_backup_restore"></a>
<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
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.
This can be done using the Script tool:
</p>
<pre>
java org.h2.tools.Script -url jdbc:h2:~/test -user sa -script test.zip -options compression zip
</pre>
<p>
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.
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.
<h3>Restore from a Script</h3>
<p>
To restore a database from a SQL script file, you can use the RunScript tool:
</p>
<pre>
java org.h2.tools.RunScript -url jdbc:h2:~/test -user sa -script test.zip -options compression zip
</pre>
<p>
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 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
Other than the SCRIPT statement, the BACKUP statement does not lock the
database objects, and therefore does not block other users. The resulting
backup is transactionally consistent:
</p>
<pre>
BACKUP TO 'backup.zip'
</pre>
<p>
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.
</p>
......@@ -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
exception will occur: java.security.AccessControlException: access denied (java.io.FilePermission ... read).
Example permission tags:
</p>
<pre>
&lt;security>
&lt;all-permissions/>
&lt;/security>
</pre>
</p>
<br /><a name="connection_pool"></a>
<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
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
connection pool is used as follows:
</p>
<pre>
// init
import org.h2.jdbcx.*;
......@@ -620,7 +643,6 @@ conn.close();
// dispose
cp.dispose();
</pre>
</p>
<br /><a name="fulltext"></a>
<h2>Fulltext Search</h2>
......@@ -721,9 +743,11 @@ There are no restrictions on the assigned values; large objects (LOBs) are suppo
<h2>Date and Time</h2>
<p>
Date, time and timestamp values support ISO 8601 formatting, including time zone:
</p>
<pre>
CALL TIMESTAMP '2008-01-01 12:00:00+01:00';
</pre>
<p>
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).
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;
import org.h2.message.Message;
import org.h2.result.LocalResult;
import org.h2.util.ObjectArray;
import org.h2.util.StringUtils;
import org.h2.value.Value;
/**
* A prepared statement.
......@@ -288,7 +290,15 @@ public abstract class Prepared {
buff.append(i + 1);
buff.append(": ");
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("}");
params = buff.toString();
......
......@@ -947,7 +947,16 @@ public class ErrorCode {
/**
* 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.
* 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;
......
......@@ -16,6 +16,7 @@ public class InternalException extends RuntimeException {
private Exception cause;
public InternalException(Exception e) {
super(e.getMessage());
cause = e;
}
......
......@@ -116,9 +116,8 @@ Initial Developer: H2 Group
</c:forEach>
</table>
</form>
<p>
<form name="shutdown" method="post" action="adminShutdown.do?jsessionid=${sessionId}">
<input type="submit" class="button" value="${text.adminShutdown}" />
</form>
</p>
<br />
<form name="shutdown" method="post" action="adminShutdown.do?jsessionid=${sessionId}">
<input type="submit" class="button" value="${text.adminShutdown}" />
</form>
</body></html>
\ No newline at end of file
......@@ -10,7 +10,7 @@ Initial Developer: H2 Group
<link rel="stylesheet" type="text/css" href="stylesheet.css" />
</head>
<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">
<!--
function set(s) {
......
......@@ -12,6 +12,15 @@ h1, h2, h3, h4, h5 {
font-weight: bold;
}
a {
text-decoration: none;
color: #0000ff;
}
a:hover {
text-decoration: underline;
}
body {
margin: 4px;
}
......@@ -37,31 +46,21 @@ h3 {
font-size: 10pt;
}
ul {
list-style-type: circle;
list-style-position: outside;
padding-left: 20px;
}
li {
margin-top: 6px;
}
ol {
list-style-type: upper-roman;
list-style-position: outside;
}
table {
background-color: #ffffff;
border-collapse: collapse;
border: 1px solid #aca899;
}
th {
font-size: 9pt;
font-weight: normal;
text-align: left;
background-color: #ece9d8;
padding: 2px;
border: 1px solid #aca899;
}
td {
background-color: #ffffff;
font-size: 9pt;
......@@ -71,14 +70,26 @@ td {
border: 1px solid #aca899;
}
form {
}
textarea {
width: 100%;
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 {
background-color: #f4f0e0;
margin: 10px;
......@@ -182,43 +193,6 @@ p.error {
input.button {
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 {
border: 0px;
......@@ -261,6 +235,10 @@ td.content {
border-left:1px solid #aca899;
}
.contentDiv {
margin:10px;
}
tr.contentResult {
border:0px;
border-top:1px solid #aca899;
......@@ -273,10 +251,6 @@ td.contentResult {
border-left:1px solid #aca899;
}
.contentDiv {
margin:10px;
}
table.autoComp {
background-color: #e0ecff;
border: 1px solid #7f9db9;
......
......@@ -492,6 +492,8 @@ public class ValueLob extends Value {
}
} catch (IOException e) {
throw Message.convertToInternal(Message.convertIOException(e, fileName));
} catch (SQLException e) {
throw Message.convertToInternal(e);
}
}
......@@ -541,7 +543,11 @@ public class ValueLob extends Value {
if (type == Value.CLOB) {
return getReader();
} else {
return getInputStream();
try {
return getInputStream();
} catch (SQLException e) {
throw Message.convertToInternal(e);
}
}
}
......@@ -553,18 +559,14 @@ public class ValueLob extends Value {
}
}
public InputStream getInputStream() {
try {
if (fileName == null) {
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);
public InputStream getInputStream() throws SQLException {
if (fileName == null) {
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);
}
public void set(PreparedStatement prep, int parameterIndex) throws SQLException {
......
......@@ -159,8 +159,6 @@ java org.h2.test.TestAll timer
/*
fix ee te
drop table t1;
drop table t2;
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 );
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;
test case for out of memory (try to corrupt the database using out of memory)
analyzer configuration option for the fulltext search
......
......@@ -24,6 +24,10 @@ public class Build extends BuildBase {
jarSmall();
docs();
}
public void spellcheck() {
java("org.h2.build.doc.SpellChecker", null);
}
public void docs() {
javadoc();
......@@ -32,7 +36,6 @@ public class Build extends BuildBase {
java("org.h2.build.code.CheckTextFiles", 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.indexer.Indexer", null);
java("org.h2.build.doc.MergeDocs", null);
java("org.h2.build.doc.WebSite", null);
......
......@@ -58,7 +58,7 @@ public class BuildBase {
projectHelp();
break;
}
out.println("Running target " + a);
out.println("Target: " + a);
invoke(m, this, new Object[0]);
}
}
......@@ -147,6 +147,7 @@ public class BuildBase {
protected void javadoc(String[] args) {
int result;
try {
out.println("Javadoc");
Class clazz = Class.forName("com.sun.tools.javadoc.Main");
Method execute = clazz.getMethod("execute", new Class[] { String[].class });
result = ((Integer) invoke(execute, null, new Object[] { args })).intValue();
......@@ -274,7 +275,7 @@ public class BuildBase {
return path;
}
protected void writeFile(File file, byte[] data) {
public static void writeFile(File file, byte[] data) {
try {
RandomAccessFile ra = new RandomAccessFile(file, "rw");
ra.write(data);
......@@ -284,7 +285,7 @@ public class BuildBase {
}
}
protected byte[] readFile(File file) {
public static byte[] readFile(File file) {
try {
RandomAccessFile ra = new RandomAccessFile(file, "r");
long len = ra.length();
......@@ -306,10 +307,12 @@ public class BuildBase {
}
protected void jar(String destFile, String basePath, List files) {
out.println("Jar " + destFile);
zipOrJar(destFile, basePath, files, false, false, true);
}
protected void zip(String destFile, String basePath, List files, boolean storeOnly, boolean sortBySuffix) {
out.println("Zip " + destFile);
zipOrJar(destFile, basePath, files, storeOnly, sortBySuffix, false);
}
......@@ -398,7 +401,7 @@ public class BuildBase {
}
protected void java(String className, String[] args) {
out.println("Executing " + className);
out.println("Running " + className);
if (args == null) {
args = new String[0];
}
......
......@@ -37,7 +37,6 @@ public class CheckTextFiles {
boolean hasError;
void run() throws Exception {
System.out.println(getClass().getName());
String baseDir = "src";
check(new File(baseDir));
if (hasError) {
......
......@@ -40,7 +40,6 @@ public class GenerateDoc {
Bnf bnf;
void run(String[] args) throws Exception {
System.out.println(getClass().getName());
for (int i = 0; i < args.length; i++) {
if (args[i].equals("-in")) {
inDir = args[++i];
......
......@@ -6,17 +6,14 @@
package org.h2.build.doc;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.io.StringWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
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
......@@ -130,14 +127,7 @@ public class SpellChecker {
if (!ok) {
throw new IOException("Unsupported suffix: " + suffix + " for file: " + fileName);
}
FileReader reader = null;
String text = null;
try {
reader = new FileReader(file);
text = readStringAndClose(reader, -1);
} finally {
IOUtils.closeSilently(reader);
}
String text = new String(BuildBase.readFile(file));
if (fileName.endsWith("dictionary.txt")) {
addToDictionary = true;
} else {
......@@ -269,23 +259,4 @@ public class SpellChecker {
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
compressibility ext crc enumerate components mkdir jant downloading mismatch
timebomb thinks technotes chmod overloading javase flux solves fastest
quickstarter bridge bpm trust guides improvements customizing easiest
workflow seque
\ No newline at end of file
workflow seque npl netstat ano spellcheck
\ No newline at end of file
......@@ -44,7 +44,6 @@ public class Indexer {
}
void run(String[] args) throws Exception {
System.out.println(getClass().getName());
String dir = "docs";
String destDir = "docs/html";
for (int i = 0; i < args.length; i++) {
......@@ -55,7 +54,6 @@ public class Indexer {
}
}
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",
"javadoc/index.html", "javadoc/classes.html", "javadoc/allclasses-frame.html",
"javadoc/allclasses-noframe.html", "javadoc/constant-values.html", "javadoc/overview-frame.html",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论