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

--no commit message

--no commit message
上级 8f83bfd0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
<!--
Copyright 2004-2007 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
Initial Developer: H2 Group
-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
......@@ -19,7 +19,7 @@ Tutorial
<a href="#creating_new_databases">
Creating New Databases</a><br />
<a href="#using_server">
Using the Server</a><br />
Using the Server</a><br />
<a href="#using_hibernate">
Using Hibernate</a><br />
<a href="#web_applications">
......@@ -55,7 +55,7 @@ Depending on your platform and environment, there are multiple ways to start the
When using the Sun JDK 1.4 or 1.5, a window with the title 'H2 Console ' should appear.
When using the Sun JDK 1.6, an icon will be added to the system tray:
<img src="images/h2.png" alt="[H2 icon]" /><br />
If you don't get the window and the system tray icon,
If you don't get the window and the system tray icon,
then maybe Java is not installed correctly (in this case, try another way to start the application).
A browser window should open and point to the Login page http://localhost:8082).
</td>
......@@ -64,8 +64,8 @@ Depending on your platform and environment, there are multiple ways to start the
<td>Windows</td>
<td>
Open a file browser, navigate to h2/bin, and double click on h2.bat.<br />
A console window appears. If there is a problem, you will see an error message
in this window. A browser window will open and point to the Login page
A console window appears. If there is a problem, you will see an error message
in this window. A browser window will open and point to the Login page
(URL: http://localhost:8082).
</td>
</tr>
......@@ -88,7 +88,7 @@ let the firewall block those connections. The connection from the local machine
Only if you want other computers to access the database on this computer, you need allow remote connections
in the firewall.
</p><p>
A small firewall is already built into the server: other computers may not connect to the server by default.
A small firewall is already built into the server: other computers may not connect to the server by default.
To change this, go to 'Preferences' and select 'Allow connections from other computers'.
</p>
......@@ -96,7 +96,7 @@ To change this, go to 'Preferences' and select 'Allow connections from other com
<p>
The native version does not require Java, because it is compiled using GCJ.
However H2 does currently not run stable with GCJ on Windows
It is possible to compile the software to different platforms.
It is possible to compile the software to different platforms.
</p>
<h3>Testing Java</h3>
......@@ -110,7 +110,7 @@ If you get an error message, you may need to add the Java binary directory to th
<h3>Error Message 'Port is in use'</h3>
<p>
You can only start one instance of the H2 Console,
You can only start one instance of the H2 Console,
otherwise you will get the following error message:
<code>Port is in use, maybe another ... server already running on...</code>.
It is possible to start multiple console applications on the same computer (using different ports),
......@@ -127,7 +127,7 @@ The relevant entry is webPort.
<h3>Starting Successfully</h3>
<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:
<pre>
H2 Server running on port 9092
......@@ -164,7 +164,7 @@ At the login page, you need to provide connection information to connect to a da
Set the JDBC driver class of your database, the JDBC URL, user name and password.
If you are done, click [Connect].
</p><p>
You can save and reuse previously saved settings. The settings are stored in the
You can save and reuse previously saved settings. The settings are stored in the
Application Properties file.
</p>
......@@ -177,8 +177,8 @@ by clicking on the message.
<h3>Adding Database Drivers</h3>
<p>
Additional database drivers can be registered by adding the Jar file location of the driver to the environment
variables H2DRIVERS or CLASSPATH. Example (Windows): To add the database driver library
C:\Programs\hsqldb\lib\hsqldb.jar, set the environment variable H2DRIVERS to
variables H2DRIVERS or CLASSPATH. Example (Windows): To add the database driver library
C:\Programs\hsqldb\lib\hsqldb.jar, set the environment variable H2DRIVERS to
C:\Programs\hsqldb\lib\hsqldb.jar.
</p><p>
Multiple drivers can be set; each entry needs to be separated with a ';' (Windows) or ':' (other operating systems).
......@@ -207,8 +207,8 @@ For, example if you type 'SELECT * FROM TEST T WHERE T.' then the table TEST is
On the browser, click 'Disconnect' on the toolbar panel. You will be logged out of the database.
However, the server is still running and ready to accept new sessions.
</p><p>
To stop the server, right click on the system tray icon and select [Exit].
If you don't have the icon (because you started it in another way),
To stop the server, right click on the system tray icon and select [Exit].
If you don't have the icon (because you started it in another way),
press [Ctrl]+[C] on the console where the server was started (Windows),
or close the console window.
</p>
......@@ -216,16 +216,16 @@ or close the console window.
<br /><a name="connecting_using_jdbc"></a>
<h2>Connecting to a Database using JDBC</h2>
<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:
<pre>
import java.sql.*;
public class Test {
public static void main(String[] a)
public static void main(String[] a)
throws Exception {
Class.forName("org.h2.Driver");
Connection conn = DriverManager.
getConnection("jdbc:h2:~/test", "sa", "");
getConnection("jdbc:h2:~/test", "sa", "");
// add application code here
}
}
......@@ -242,7 +242,7 @@ Please note that in this database, user names are not case sensitive, but passwo
<br /><a name="creating_new_databases"></a>
<h2>Creating New Databases</h2>
<p>
By default, if the database specified in the URL does not yet exist, a new (empty)
By default, if the database specified in the URL does not yet exist, a new (empty)
database is created automatically. The user that created the database automatically becomes
the administrator of this database.
</p>
......@@ -264,7 +264,7 @@ This will start the Server with the default options. To get the list of options
<pre>
java org.h2.tools.Server -?
</pre>
There are options available to use a different ports, and start or not start
There are options available to use a 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>
......@@ -296,7 +296,7 @@ server.stop();
<h3>Stopping a TCP Server from Another Process</h3>
<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:
<pre>
java org.h2.tools.Server -tcpShutdown tcp://localhost:9092
......@@ -306,7 +306,7 @@ To stop the server from a user application, use the following code:
org.h2.tools.Server.shutdownTcpServer("tcp://localhost:9094");
</pre>
This function will call System.exit on the server.
This function should be called after all connection to the databases are closed
This function should be called after all connection to the databases are closed
to avoid recovery when the databases are opened the next time.
To stop remote server, remote connections must be enabled on the server.
</p>
......@@ -324,7 +324,7 @@ There currently are a few limitations when using the server or cluster mode:
<br /><a name="using_hibernate"></a>
<h2>Using Hibernate</h2>
<p>
This database supports Hibernate version 3.1 and newer. You can use the HSQLDB Dialect,
This database supports Hibernate version 3.1 and newer. You can use the HSQLDB Dialect,
or the native H2 Dialect that is available in the file src/tools/org/h2/tools/hibernate/H2Dialect.txt.
The H2 dialect is included in newer version of Hibernate. For versions where the dialect is missing, you need to copy the file
into the folder src\org\hibernate\dialect (Hibernate 3.1), rename it to H2Dialect.java and re-compile hibernate.
......@@ -360,7 +360,7 @@ bad if they don't get closed).
<h3>Server Mode</h3>
<p>
The server mode is similar, but it allows you to run the server in another process.
The server mode is similar, but it allows you to run the server in another process.
</p>
<h3>Using a Servlet Listener to Start and Stop a Database</h3>
......@@ -378,7 +378,7 @@ For details on how to access the database, see the code DbStarter.java
<br /><a name="csv"></a>
<h2>CSV (Comma Separated Values) Support</h2>
<p>
The CSV file support can be used inside the database using the functions CSVREAD and CSVWRITE,
The CSV file support can be used inside the database using the functions CSVREAD and CSVWRITE,
and the CSV library can be used outside the database as a standalone tool.
</p>
......@@ -447,7 +447,7 @@ and then execute the SQL script using the new engine.
<p>
There are different ways to backup a database. For example, it is possible to copy the database files.
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:
<pre>
java org.h2.tools.Script -url jdbc:h2:~/test -user sa -script test.zip -options compression zip
......@@ -475,8 +475,8 @@ need to be available on the server side.
<h3>Online Backup</h3>
<p>
The BACKUP SQL statement and the Backup tool both create a zip file
with all database files. However, the contents of this file are not human readable.
The BACKUP SQL statement and the Backup tool both create a zip file
with all database files. However, the contents of this file are not human readable.
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:
......@@ -490,7 +490,7 @@ the database must not be in use while running this program.
<br /><a name="open_office"></a>
<h2>Using OpenOffice Base</h2>
<p>
OpenOffice.org Base supports database access over the JDBC API. To connect to a H2 database
OpenOffice.org Base supports database access over the JDBC API. To connect to a H2 database
using OpenOffice Base, you first need to add the JDBC driver to OpenOffice.
The steps to connect to a H2 database are:
</p>
......@@ -509,8 +509,8 @@ Now you can access the database stored in the directory C:/temp.
<br /><a name="web_start"></a>
<h2>Java Web Start / JNLP</h2>
<p>
When using Java Web Start / JNLP (Java Network Launch Protocol), permissions tags must be set in the .jnlp file,
and the application .jar file must be signed. Otherwise, when trying to write to the file system, the following
When using Java Web Start / JNLP (Java Network Launch Protocol), permissions tags must be set in the .jnlp file,
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:
<pre>
......@@ -523,7 +523,7 @@ Example permission tags:
<br /><a name="fulltext"></a>
<h2>Fulltext Search</h2>
<p>
H2 supports Lucene full text search and native full text search implementation.
H2 supports Lucene full text search and native full text search implementation.
</p>
<h3>Using the Native Full Text Search</h3>
......@@ -543,8 +543,8 @@ INSERT INTO TEST VALUES(1, 'Hello World');
CALL FT_CREATE_INDEX('PUBLIC', 'TEST', NULL);
</pre>
<p>
PUBLIC is the schema, TEST is the table name. The list of column names (column separated) is optional,
in this case all columns are indexed. The index is updated in read time.
PUBLIC is the schema, TEST is the table name. The list of column names (column separated) is optional,
in this case all columns are indexed. The index is updated in read time.
To search the index, use the following query:
</p>
<pre>
......@@ -559,7 +559,7 @@ org.h2.fulltext.FullText.search(conn, text, limit, offset)
<h3>Using the Lucene Fulltext Search</h3>
<p>
To use the Lucene full text search, you first need to rename the file FullTextLucene.java.txt to FullTestLucene.java and compile it. Also, you need the Lucene library in the classpath.
To use the Lucene full text search, you need the Lucene library in the classpath.
To initialize, call:
</p>
<pre>
......@@ -575,7 +575,7 @@ INSERT INTO TEST VALUES(1, 'Hello World');
CALL FTL_CREATE_INDEX('PUBLIC', 'TEST', NULL);
</pre>
<p>
PUBLIC is the schema, TEST is the table name. The list of column names (column separated) is optional,
PUBLIC is the schema, TEST is the table name. The list of column names (column separated) is optional,
in this case all columns are indexed. The index is updated in read time. To search the index, use the following query:
</p>
<pre>
......
......@@ -1718,7 +1718,13 @@ public class Parser {
r = new Aggregate(database, Aggregate.COUNT_ALL, null, currentSelect, false);
} else {
boolean distinct = readIf("DISTINCT");
r = new Aggregate(database, Aggregate.COUNT, readExpression(), currentSelect, distinct);
Expression on = readExpression();
if (on instanceof Wildcard && !distinct) {
// PostgreSQL compatibility: count(t.*)
r = new Aggregate(database, Aggregate.COUNT_ALL, null, currentSelect, false);
} else {
r = new Aggregate(database, Aggregate.COUNT, on, currentSelect, distinct);
}
}
} else if (aggregateType == Aggregate.GROUP_CONCAT) {
boolean distinct = readIf("DISTINCT");
......
......@@ -11,6 +11,7 @@ import org.h2.engine.Session;
import org.h2.message.Message;
import org.h2.table.ColumnResolver;
import org.h2.table.TableFilter;
import org.h2.util.StringUtils;
import org.h2.value.Value;
/**
......@@ -76,7 +77,11 @@ public class Wildcard extends Expression {
}
public String getSQL() {
throw Message.getInternalError();
if (table == null) {
return "*";
} else {
return StringUtils.quoteIdentifier(table) + ".*";
}
}
public void updateAggregate(Session session) {
......
select count(d.*) from dual d group by d.x;
> 1;
create table test(id int);
select count(*) from (select * from ((select * from test) union (select * from test)) a) b where id = 0;
> 0;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论