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

--no commit message

--no commit message
上级 7d79a0e6
......@@ -201,6 +201,9 @@ To use the MVCC feature, append MVCC=TRUE to the database URL:
jdbc:h2:~/test;MVCC=TRUE
</pre>
</p>
<p>
The MVCC feature is not fully tested yet.
</p>
<br /><a name="clustering"></a>
<h2>Clustering / High Availability</h2>
......
......@@ -16,9 +16,9 @@ Change Log
<h2>Next Version (unreleased)</h2>
<ul>
<li>The performance of text comparison has been improved when using locale sensitive
string comparison (SET COLLATOR). Now CollationKey is used with a LRU cache.
The default cache size is 10000, and can be changed using the system property
h2.collatorCacheSize. Use 0 to disable the cache.
string comparison (SET COLLATOR). Now CollationKey is used with a LRU cache.
The default cache size is 10000, and can be changed using the system property
h2.collatorCacheSize. Use 0 to disable the cache.
</li><li>UPDATE SET column=DEFAULT is now supported.
</li></ul>
......
......@@ -185,8 +185,6 @@ 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).
Spaces in the path names are supported. The settings must not be quoted.
</p><p>
Only the Java version supports additional drivers (this feature is not supported by the Native version).
</p>
<h3>Using the Application</h3>
......
......@@ -190,658 +190,661 @@ The MVCC feature allows higher concurrency than using (table level or row level)
@advanced_1063_p
To use the MVCC feature, append MVCC=TRUE to the database URL:
@advanced_1064_h2
@advanced_1064_p
The MVCC feature is not fully tested yet.
@advanced_1065_h2
Clustering / High Availability
@advanced_1065_p
@advanced_1066_p
This database supports a simple clustering / high availability mechanism. The architecture is: two database servers run on two different computers, and on both computers is a copy of the same database. If both servers run, each database operation is executed on both computers. If one server fails (power, hardware or network failure), the other server can still continue to work. From this point on, the operations will be executed only on one server until the other server is back up.
@advanced_1066_p
@advanced_1067_p
Clustering can only be used in the server mode (the embedded mode does not support clustering). It is possible to restore the cluster without stopping the server, however it is critical that no other application is changing the data in the first database while the second database is restored, so restoring the cluster is currently a manual process.
@advanced_1067_p
@advanced_1068_p
To initialize the cluster, use the following steps:
@advanced_1068_li
@advanced_1069_li
Create a database
@advanced_1069_li
@advanced_1070_li
Use the CreateCluster tool to copy the database to another location and initialize the clustering. Afterwards, you have two databases containing the same data.
@advanced_1070_li
@advanced_1071_li
Start two servers (one for each copy of the database)
@advanced_1071_li
@advanced_1072_li
You are now ready to connect to the databases with the client application(s)
@advanced_1072_h3
@advanced_1073_h3
Using the CreateCluster Tool
@advanced_1073_p
@advanced_1074_p
To understand how clustering works, please try out the following example. In this example, the two databases reside on the same computer, but usually, the databases will be on different servers.
@advanced_1074_li
@advanced_1075_li
Create two directories: server1 and server2. Each directory will simulate a directory on a computer.
@advanced_1075_li
@advanced_1076_li
Start a TCP server pointing to the first directory. You can do this using the command line:
@advanced_1076_li
@advanced_1077_li
Start a second TCP server pointing to the second directory. This will simulate a server running on a second (redundant) computer. You can do this using the command line:
@advanced_1077_li
@advanced_1078_li
Use the CreateCluster tool to initialize clustering. This will automatically create a new, empty database if it does not exist. Run the tool on the command line:
@advanced_1078_li
@advanced_1079_li
You can now connect to the databases using an application or the H2 Console using the JDBC URL jdbc:h2:tcp://localhost:9101,localhost:9102/test
@advanced_1079_li
@advanced_1080_li
If you stop a server (by killing the process), you will notice that the other machine continues to work, and therefore the database is still accessible.
@advanced_1080_li
@advanced_1081_li
To restore the cluster, you first need to delete the database that failed, then restart the server that was stopped, and re-run the CreateCluster tool.
@advanced_1081_h3
@advanced_1082_h3
Clustering Algorithm and Limitations
@advanced_1082_p
@advanced_1083_p
Read-only queries are only executed against the first cluster node, but all other statements are executed against all nodes. There is currently no load balancing made to avoid problems with transactions. The following functions may yield different results on different cluster nodes and must be executed with care: RANDOM_UUID(), SECURE_RAND(), SESSION_ID(), MEMORY_FREE(), MEMORY_USED(), CSVREAD(), CSVWRITE(), RAND() [when not using a seed]. Those functions should not be used directly in modifying statements (for example INSERT, UPDATE, or MERGE). However, they can be used in read-only statements and the result can then be used for modifying statements.
@advanced_1083_h2
@advanced_1084_h2
Two Phase Commit
@advanced_1084_p
@advanced_1085_p
The two phase commit protocol is supported. 2-phase-commit works as follows:
@advanced_1085_li
@advanced_1086_li
Autocommit needs to be switched off
@advanced_1086_li
@advanced_1087_li
A transaction is started, for example by inserting a row
@advanced_1087_li
@advanced_1088_li
The transaction is marked 'prepared' by executing the SQL statement <code>PREPARE COMMIT transactionName</code>
@advanced_1088_li
@advanced_1089_li
The transaction can now be committed or rolled back
@advanced_1089_li
@advanced_1090_li
If a problem occurs before the transaction was successfully committed or rolled back (for example because a network problem occurred), the transaction is in the state 'in-doubt'
@advanced_1090_li
@advanced_1091_li
When re-connecting to the database, the in-doubt transactions can be listed with <code>SELECT * FROM INFORMATION_SCHEMA.IN_DOUBT</code>
@advanced_1091_li
@advanced_1092_li
Each transaction in this list must now be committed or rolled back by executing <code>COMMIT TRANSACTION transactionName</code> or <code>ROLLBACK TRANSACTION transactionName</code>
@advanced_1092_li
@advanced_1093_li
The database needs to be closed and re-opened to apply the changes
@advanced_1093_h2
@advanced_1094_h2
Compatibility
@advanced_1094_p
@advanced_1095_p
This database is (up to a certain point) compatible to other databases such as HSQLDB, MySQL and PostgreSQL. There are certain areas where H2 is incompatible.
@advanced_1095_h3
@advanced_1096_h3
Transaction Commit when Autocommit is On
@advanced_1096_p
@advanced_1097_p
At this time, this database engine commits a transaction (if autocommit is switched on) just before returning the result. For a query, this means the transaction is committed even before the application scans through the result set, and before the result set is closed. Other database engines may commit the transaction in this case when the result set is closed.
@advanced_1097_h3
@advanced_1098_h3
Keywords / Reserved Words
@advanced_1098_p
@advanced_1099_p
There is a list of keywords that can't be used as identifiers (table names, column names and so on), unless they are quoted (surrounded with double quotes). The list is currently:
@advanced_1099_p
@advanced_1100_p
CURRENT_TIMESTAMP, CURRENT_TIME, CURRENT_DATE, CROSS, DISTINCT, EXCEPT, EXISTS, FROM, FOR, FALSE, FULL, GROUP, HAVING, INNER, INTERSECT, IS, JOIN, LIKE, MINUS, NATURAL, NOT, NULL, ON, ORDER, PRIMARY, ROWNUM, SELECT, SYSDATE, SYSTIME, SYSTIMESTAMP, TODAY, TRUE, UNION, WHERE
@advanced_1100_p
@advanced_1101_p
Certain words of this list are keywords because they are functions that can be used without '()' for compatibility, for example CURRENT_TIMESTAMP.
@advanced_1101_h2
@advanced_1102_h2
Run as Windows Service
@advanced_1102_p
@advanced_1103_p
Using a native wrapper / adapter, Java applications can be run as a Windows Service. There are various tools available to do that. The Java Service Wrapper from Tanuki Software, Inc. ( <a href="http://wrapper.tanukisoftware.org">http://wrapper.tanukisoftware.org</a> ) is included in the installation. Batch files are provided to install, start, stop and uninstall the H2 Database Engine Service. This service contains the TCP Server and the H2 Console web application. The batch files are located in the directory H2/service.
@advanced_1103_h3
@advanced_1104_h3
Install the Service
@advanced_1104_p
@advanced_1105_p
The service needs to be registered as a Windows Service first. To do that, double click on 1_install_service.bat. If successful, a command prompt window will pop up and disappear immediately. If not, a message will appear.
@advanced_1105_h3
@advanced_1106_h3
Start the Service
@advanced_1106_p
@advanced_1107_p
You can start the H2 Database Engine Service using the service manager of Windows, or by double clicking on 2_start_service.bat. Please note that the batch file does not print an error message if the service is not installed.
@advanced_1107_h3
@advanced_1108_h3
Connect to the H2 Console
@advanced_1108_p
@advanced_1109_p
After installing and starting the service, you can connect to the H2 Console application using a browser. Double clicking on 3_start_browser.bat to do that. The default port (8082) is hard coded in the batch file.
@advanced_1109_h3
@advanced_1110_h3
Stop the Service
@advanced_1110_p
@advanced_1111_p
To stop the service, double click on 4_stop_service.bat. Please note that the batch file does not print an error message if the service is not installed or started.
@advanced_1111_h3
@advanced_1112_h3
Uninstall the Service
@advanced_1112_p
@advanced_1113_p
To uninstall the service, double click on 5_uninstall_service.bat. If successful, a command prompt window will pop up and disappear immediately. If not, a message will appear.
@advanced_1113_h2
@advanced_1114_h2
ODBC Driver
@advanced_1114_p
@advanced_1115_p
This database does not come with its own ODBC driver at this time, but it supports the PostgreSQL network protocol. Therefore, the PostgreSQL ODBC driver can be used. Support for the PostgreSQL network protocol is quite new and should be viewed as experimental. It should not be used for production applications.
@advanced_1115_p
@advanced_1116_p
At this time, the PostgreSQL ODBC driver does not work on 64 bit versions of Windows. For more information, see: <a href="http://svr5.postgresql.org/pgsql-odbc/2005-09/msg00127.php">ODBC Driver on Windows 64 bit</a>
@advanced_1116_h3
@advanced_1117_h3
ODBC Installation
@advanced_1117_p
@advanced_1118_p
First, the ODBC driver must be installed. Any recent PostgreSQL ODBC driver should work, however version 8.2.4 or newer is recommended. The Windows version of the PostgreSQL ODBC driver is available at <a href="http://www.postgresql.org/ftp/odbc/versions/msi">http://www.postgresql.org/ftp/odbc/versions/msi</a> .
@advanced_1118_h3
@advanced_1119_h3
Starting the Server
@advanced_1119_p
@advanced_1120_p
After installing the ODBC driver, start the H2 Server using the command line:
@advanced_1120_p
@advanced_1121_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:
@advanced_1121_p
@advanced_1122_p
The PG server can be started and stopped from within a Java application as follows:
@advanced_1122_p
@advanced_1123_p
By default, only connections from localhost are allowed. To allow remote connections, use <code>-pgAllowOthers true</code> when starting the server.
@advanced_1123_h3
@advanced_1124_h3
ODBC Configuration
@advanced_1124_p
@advanced_1125_p
After installing the driver, a new Data Source must be added. In Windows, run <code>odbcad32.exe</code> to open the Data Source Administrator. Then click on 'Add...' and select the PostgreSQL Unicode driver. Then click 'Finish'. You will be able to change the connection properties:
@advanced_1125_th
@advanced_1126_th
Property
@advanced_1126_th
@advanced_1127_th
Example
@advanced_1127_th
@advanced_1128_th
Remarks
@advanced_1128_td
@advanced_1129_td
Data Source
@advanced_1129_td
@advanced_1130_td
H2 Test
@advanced_1130_td
@advanced_1131_td
The name of the ODBC Data Source
@advanced_1131_td
@advanced_1132_td
Database
@advanced_1132_td
@advanced_1133_td
test
@advanced_1133_td
@advanced_1134_td
The database name. Only simple names are supported at this time;
@advanced_1134_td
@advanced_1135_td
relative or absolute path are not supported in the database name.
@advanced_1135_td
@advanced_1136_td
By default, the database is stored in the current working directory
@advanced_1136_td
@advanced_1137_td
where the Server is started except when the -baseDir setting is used.
@advanced_1137_td
@advanced_1138_td
The name must be at least 3 characters.
@advanced_1138_td
@advanced_1139_td
Server
@advanced_1139_td
@advanced_1140_td
localhost
@advanced_1140_td
@advanced_1141_td
The server name or IP address.
@advanced_1141_td
@advanced_1142_td
By default, only remote connections are allowed
@advanced_1142_td
@advanced_1143_td
User Name
@advanced_1143_td
@advanced_1144_td
sa
@advanced_1144_td
@advanced_1145_td
The database user name.
@advanced_1145_td
@advanced_1146_td
SSL Mode
@advanced_1146_td
@advanced_1147_td
disabled
@advanced_1147_td
@advanced_1148_td
At this time, SSL is not supported.
@advanced_1148_td
@advanced_1149_td
Port
@advanced_1149_td
@advanced_1150_td
5435
@advanced_1150_td
@advanced_1151_td
The port where the PG Server is listening.
@advanced_1151_td
@advanced_1152_td
Password
@advanced_1152_td
@advanced_1153_td
sa
@advanced_1153_td
@advanced_1154_td
The database password.
@advanced_1154_p
@advanced_1155_p
Afterwards, you may use this data source.
@advanced_1155_h3
@advanced_1156_h3
PG Protocol Support Limitations
@advanced_1156_p
@advanced_1157_p
At this time, only a subset of the PostgreSQL network protocol is implemented. Also, there may be compatibility problems on the SQL level, with the catalog, or with text encoding. Problems are fixed as they are found. Currently, statements can not be cancelled when using the PG protocol.
@advanced_1157_p
@advanced_1158_p
PostgreSQL ODBC Driver Setup requires a database password, that means it is not possible to connect to H2 databases without password. This is a limitation of the ODBC driver.
@advanced_1158_h3
@advanced_1159_h3
Security Considerations
@advanced_1159_p
@advanced_1160_p
Currently, the PG Server does not support challenge response or encrypt passwords. This may be a problem if an attacker can listen to the data transferred between the ODBC driver and the server, because the password is readable to the attacker. Also, it is currently not possible to use encrypted SSL connections. Therefore the ODBC driver should not be used where security is important.
@advanced_1160_h2
@advanced_1161_h2
ACID
@advanced_1161_p
@advanced_1162_p
In the database world, ACID stands for:
@advanced_1162_li
@advanced_1163_li
Atomicity: Transactions must be atomic, meaning either all tasks are performed or none.
@advanced_1163_li
@advanced_1164_li
Consistency: All operations must comply with the defined constraints.
@advanced_1164_li
@advanced_1165_li
Isolation: Transactions must be isolated from each other.
@advanced_1165_li
@advanced_1166_li
Durability: Committed transaction will not be lost.
@advanced_1166_h3
@advanced_1167_h3
Atomicity
@advanced_1167_p
@advanced_1168_p
Transactions in this database are always atomic.
@advanced_1168_h3
@advanced_1169_h3
Consistency
@advanced_1169_p
@advanced_1170_p
This database is always in a consistent state. Referential integrity rules are always enforced.
@advanced_1170_h3
@advanced_1171_h3
Isolation
@advanced_1171_p
@advanced_1172_p
For H2, as with most other database systems, the default isolation level is 'read committed'. This provides better performance, but also means that transactions are not completely isolated. H2 supports the transaction isolation levels 'serializable', 'read committed', and 'read uncommitted'.
@advanced_1172_h3
@advanced_1173_h3
Durability
@advanced_1173_p
@advanced_1174_p
This database does not guarantee that all committed transactions survive a power failure. Tests show that all databases sometimes lose transactions on power failure (for details, see below). Where losing transactions is not acceptable, a laptop or UPS (uninterruptible power supply) should be used. If durability is required for all possible cases of hardware failure, clustering should be used, such as the H2 clustering mode.
@advanced_1174_h2
@advanced_1175_h2
Durability Problems
@advanced_1175_p
@advanced_1176_p
Complete durability means all committed transaction survive a power failure. Some databases claim they can guarantee durability, but such claims are wrong. A durability test was run against H2, HSQLDB, PostgreSQL, and Derby. All of those databases sometimes lose committed transactions. The test is included in the H2 download, see org.h2.test.poweroff.Test.
@advanced_1176_h3
@advanced_1177_h3
Ways to (Not) Achieve Durability
@advanced_1177_p
@advanced_1178_p
Making sure that committed transaction are not lost is more complicated than it seems first. To guarantee complete durability, a database must ensure that the log record is on the hard drive before the commit call returns. To do that, databases use different methods. One is to use the 'synchronous write' file access mode. In Java, RandomAccessFile supports the modes "rws" and "rwd":
@advanced_1178_li
@advanced_1179_li
rwd: Every update to the file's content is written synchronously to the underlying storage device.
@advanced_1179_li
@advanced_1180_li
rws: In addition to rwd, every update to the metadata is written synchronously.
@advanced_1180_p
@advanced_1181_p
This feature is used by Derby. A test (org.h2.test.poweroff.TestWrite) with one of those modes achieves around 50 thousand write operations per second. Even when the operating system write buffer is disabled, the write rate is around 50 thousand operations per second. This feature does not force changes to disk because it does not flush all buffers. The test updates the same byte in the file again and again. If the hard drive was able to write at this rate, then the disk would need to make at least 50 thousand revolutions per second, or 3 million RPM (revolutions per minute). There are no such hard drives. The hard drive used for the test is about 7200 RPM, or about 120 revolutions per second. There is an overhead, so the maximum write rate must be lower than that.
@advanced_1181_p
@advanced_1182_p
Buffers can be flushed by calling the function fsync. There are two ways to do that in Java:
@advanced_1182_li
@advanced_1183_li
FileDescriptor.sync(). The documentation says that this forces all system buffers to synchronize with the underlying device. Sync is supposed to return after all in-memory modified copies of buffers associated with this FileDescriptor have been written to the physical medium.
@advanced_1183_li
@advanced_1184_li
FileChannel.force() (since JDK 1.4). This method is supposed to force any updates to this channel's file to be written to the storage device that contains it.
@advanced_1184_p
@advanced_1185_p
By default, MySQL calls fsync for each commit. When using one of those methods, only around 60 write operations per second can be achieved, which is consistent with the RPM rate of the hard drive used. Unfortunately, even when calling FileDescriptor.sync() or FileChannel.force(), data is not always persisted to the hard drive, because most hard drives do not obey fsync(): see 'Your Hard Drive Lies to You' at http://hardware.slashdot.org/article.pl?sid=05/05/13/0529252. In Mac OS X fsync does not flush hard drive buffers: http://lists.apple.com/archives/darwin-dev/2005/Feb/msg00072.html. So the situation is confusing, and tests prove there is a problem.
@advanced_1185_p
@advanced_1186_p
Trying to flush hard drive buffers hard, and if you do the performance is very bad. First you need to make sure that the hard drive actually flushes all buffers. Tests show that this can not be done in a reliable way. Then the maximum number of transactions is around 60 per second. Because of those reasons, the default behavior of H2 is to delay writing committed transactions.
@advanced_1186_p
@advanced_1187_p
In H2, after a power failure, a bit more than one second of committed transactions may be lost. To change the behavior, use SET WRITE_DELAY and CHECKPOINT SYNC. Most other databases support commit delay as well. In the performance comparison, commit delay was used for all databases that support it.
@advanced_1187_h3
@advanced_1188_h3
Running the Durability Test
@advanced_1188_p
@advanced_1189_p
To test the durability / non-durability of this and other databases, you can use the test application in the package org.h2.test.poweroff. Two computers with network connection are required to run this test. One computer just listens, while the test application is run (and power is cut) on the other computer. The computer with the listener application opens a TCP/IP port and listens for an incoming connection. The second computer first connects to the listener, and then created the databases and starts inserting records. The connection is set to 'autocommit', which means after each inserted record a commit is performed automatically. Afterwards, the test computer notifies the listener that this record was inserted successfully. The listener computer displays the last inserted record number every 10 seconds. Now, switch off the power manually, then restart the computer, and run the application again. You will find out that in most cases, none of the databases contains all the records that the listener computer knows about. For details, please consult the source code of the listener and test application.
@advanced_1189_h2
@advanced_1190_h2
Using the Recover Tool
@advanced_1190_p
@advanced_1191_p
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:
@advanced_1191_p
@advanced_1192_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 don't have the correct table names, so the file needs to be pre-processed manually before executing.
@advanced_1192_h2
@advanced_1193_h2
File Locking Protocols
@advanced_1193_p
@advanced_1194_p
Whenever a database is opened, a lock file is created to signal other processes that the database is in use. If database is closed, or if the process that opened the database terminates, this lock file is deleted.
@advanced_1194_p
@advanced_1195_p
In special cases (if the process did not terminate normally, for example because there was a blackout), the lock file is not deleted by the process that created it. That means the existence of the lock file is not a safe protocol for file locking. However, this software uses a challenge-response protocol to protect the database files. There are two methods (algorithms) implemented to provide both security (that is, the same database files cannot be opened by two processes at the same time) and simplicity (that is, the lock file does not need to be deleted manually by the user). The two methods are 'file method' and 'socket methods'.
@advanced_1195_h3
@advanced_1196_h3
File Locking Method 'File'
@advanced_1196_p
@advanced_1197_p
The default method for database file locking is the 'File Method'. The algorithm is:
@advanced_1197_li
@advanced_1198_li
When the lock file does not exist, it is created (using the atomic operation File.createNewFile). Then, the process waits a little bit (20ms) and checks the file again. If the file was changed during this time, the operation is aborted. This protects against a race condition when a process deletes the lock file just after one create it, and a third process creates the file again. It does not occur if there are only two writers.
@advanced_1198_li
@advanced_1199_li
If the file can be created, a random number is inserted together with the locking method ('file'). Afterwards, a watchdog thread is started that checks regularly (every second once by default) if the file was deleted or modified by another (challenger) thread / process. Whenever that occurs, the file is overwritten with the old data. The watchdog thread runs with high priority so that a change to the lock file does not get through undetected even if the system is very busy. However, the watchdog thread does use very little resources (CPU time), because it waits most of the time. Also, the watchdog only reads from the hard disk and does not write to it.
@advanced_1199_li
@advanced_1200_li
If the lock file exists, and it was modified in the 20 ms, the process waits for some time (up to 10 times). If it was still changed, an exception is thrown (database is locked). This is done to eliminate race conditions with many concurrent writers. Afterwards, the file is overwritten with a new version (challenge). After that, the thread waits for 2 seconds. If there is a watchdog thread protecting the file, he will overwrite the change and this process will fail to lock the database. However, if there is no watchdog thread, the lock file will still be as written by this thread. In this case, the file is deleted and atomically created again. The watchdog thread is started in this case and the file is locked.
@advanced_1200_p
@advanced_1201_p
This algorithm is tested with over 100 concurrent threads. In some cases, when there are many concurrent threads trying to lock the database, they block each other (meaning the file cannot be locked by any of them) for some time. However, the file never gets locked by two threads at the same time. However using that many concurrent threads / processes is not the common use case. Generally, an application should throw an error to the user if it cannot open a database, and not try again in a (fast) loop.
@advanced_1201_h3
@advanced_1202_h3
File Locking Method 'Socket'
@advanced_1202_p
@advanced_1203_p
There is a second locking mechanism implemented, but disabled by default. The algorithm is:
@advanced_1203_li
@advanced_1204_li
If the lock file does not exist, it is created. Then a server socket is opened on a defined port, and kept open. The port and IP address of the process that opened the database is written into the lock file.
@advanced_1204_li
@advanced_1205_li
If the lock file exists, and the lock method is 'file', then the software switches to the 'file' method.
@advanced_1205_li
@advanced_1206_li
If the lock file exists, and the lock method is 'socket', then the process checks if the port is in use. If the original process is still running, the port is in use and this process throws an exception (database is in use). If the original process died (for example due to a blackout, or abnormal termination of the virtual machine), then the port was released. The new process deletes the lock file and starts again.
@advanced_1206_p
@advanced_1207_p
This method does not require a watchdog thread actively polling (reading) the same file every second. The problem with this method is, if the file is stored on a network share, two processes (running on different computers) could still open the same database files, if they do not have a direct TCP/IP connection.
@advanced_1207_h2
@advanced_1208_h2
Protection against SQL Injection
@advanced_1208_h3
@advanced_1209_h3
What is SQL Injection
@advanced_1209_p
@advanced_1210_p
This database engine provides a solution for the security vulnerability known as 'SQL Injection'. Here is a short description of what SQL injection means. Some applications build SQL statements with embedded user input such as:
@advanced_1210_p
@advanced_1211_p
If this mechanism is used anywhere in the application, and user input is not correctly filtered or encoded, it is possible for a user to inject SQL functionality or statements by using specially built input such as (in this example) this password: ' OR ''='. In this case the statement becomes:
@advanced_1211_p
@advanced_1212_p
Which is always true no matter what the password stored in the database is. For more information about SQL Injection, see Glossary and Links.
@advanced_1212_h3
@advanced_1213_h3
Disabling Literals
@advanced_1213_p
@advanced_1214_p
SQL Injection is not possible if user input is not directly embedded in SQL statements. A simple solution for the problem above is to use a PreparedStatement:
@advanced_1214_p
@advanced_1215_p
This database provides a way to enforce usage of parameters when passing user input to the database. This is done by disabling embedded literals in SQL statements. To do this, execute the statement:
@advanced_1215_p
@advanced_1216_p
Afterwards, SQL statements with text and number literals are not allowed any more. That means, SQL statement of the form WHERE NAME='abc' or WHERE CustomerId=10 will fail. It is still possible to use PreparedStatements and parameters as described above. Also, it is still possible to generate SQL statements dynamically, and use the Statement API, as long as the SQL statements do not include literals. There is also a second mode where number literals are allowed: SET ALLOW_LITERALS NUMBERS. To allow all literals, execute SET ALLOW_LITERALS ALL (this is the default setting). Literals can only be enabled or disabled by an administrator.
@advanced_1216_h3
@advanced_1217_h3
Using Constants
@advanced_1217_p
@advanced_1218_p
Disabling literals also means disabling hard-coded 'constant' literals. This database supports defining constants using the CREATE CONSTANT command. Constants can be defined only when literals are enabled, but used even when literals are disabled. To avoid name clashes with column names, constants can be defined in other schemas:
@advanced_1218_p
@advanced_1219_p
Even when literals are enabled, it is better to use constants instead of hard-coded number or text literals in queries or views. With constants, typos are found at compile time, the source code is easier to understand and change.
@advanced_1219_h3
@advanced_1220_h3
Using the ZERO() Function
@advanced_1220_p
@advanced_1221_p
It is not required to create a constant for the number 0 as there is already a built-in function ZERO():
@advanced_1221_h2
@advanced_1222_h2
Restricting Class Loading and Usage
@advanced_1222_p
@advanced_1223_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:
@advanced_1223_p
@advanced_1224_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:
@advanced_1224_p
@advanced_1225_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.
@advanced_1225_h2
@advanced_1226_h2
Security Protocols
@advanced_1226_p
@advanced_1227_p
The following paragraphs document the security protocols used in this database. These descriptions are very technical and only intended for security experts that already know the underlying security primitives.
@advanced_1227_h3
@advanced_1228_h3
User Password Encryption
@advanced_1228_p
@advanced_1229_p
When a user tries to connect to a database, the combination of user name, @, and password hashed using SHA-256, and this hash value is transmitted to the database. This step does not try to an attacker from re-using the value if he is able to listen to the (unencrypted) transmission between the client and the server. But, the passwords are never transmitted as plain text, even when using an unencrypted connection between client and server. That means if a user reuses the same password for different things, this password is still protected up to some point. See also 'RFC 2617 - HTTP Authentication: Basic and Digest Access Authentication' for more information.
@advanced_1229_p
@advanced_1230_p
When a new database or user is created, a new cryptographically secure random salt value is generated. The size of the salt is 64 bit. Using the random salt reduces the risk of an attacker pre-calculating hash values for many different (commonly used) passwords.
@advanced_1230_p
@advanced_1231_p
The combination of user-password hash value (see above) and salt is hashed using SHA-256. The resulting value is stored in the database. When a user tries to connect to the database, the database combines user-password hash value with the stored salt value and calculated the hash value. Other products use multiple iterations (hash the hash value again and again), but this is not done in this product to reduce the risk of denial of service attacks (where the attacker tries to connect with bogus passwords, and the server spends a lot of time calculating the hash value for each password). The reasoning is: if the attacker has access to the hashed passwords, he also has access to the data in plain text, and therefore does not need the password any more. If the data is protected by storing it on another computer and only remotely, then the iteration count is not required at all.
@advanced_1231_h3
@advanced_1232_h3
File Encryption
@advanced_1232_p
@advanced_1233_p
The database files can be encrypted using two different algorithms: AES-128 and XTEA (using 32 rounds). The reasons for supporting XTEA is performance (XTEA is about twice as fast as AES) and to have an alternative algorithm if AES is suddenly broken.
@advanced_1233_p
@advanced_1234_p
When a user tries to connect to an encrypted database, the combination of the word 'file', @, and the file password is hashed using SHA-256. This hash value is transmitted to the server.
@advanced_1234_p
@advanced_1235_p
When a new database file is created, a new cryptographically secure random salt value is generated. The size of the salt is 64 bit. The combination of the file password hash and the salt value is hashed 1024 times using SHA-256. The reason for the iteration is to make it harder for an attacker to calculate hash values for common passwords.
@advanced_1235_p
@advanced_1236_p
The resulting hash value is used as the key for the block cipher algorithm (AES-128 or XTEA with 32 rounds). Then, an initialization vector (IV) key is calculated by hashing the key again using SHA-256. This is to make sure the IV is unknown to the attacker. The reason for using a secret IV is to protect against watermark attacks.
@advanced_1236_p
@advanced_1237_p
Before saving a block of data (each block is 8 bytes long), the following operations are executed: First, the IV is calculated by encrypting the block number with the IV key (using the same block cipher algorithm). This IV is combined with the plain text using XOR. The resulting data is encrypted using the AES-128 or XTEA algorithm.
@advanced_1237_p
@advanced_1238_p
When decrypting, the operation is done in reverse. First, the block is decrypted using the key, and then the IV is calculated combined with the decrypted text using XOR.
@advanced_1238_p
@advanced_1239_p
Therefore, the block cipher modes of operation is CBC (Cipher-block chaining), but each chain is only one block long. The advantage over the ECB (Electronic codebook) mode is that patterns in the data are not revealed, and the advantage over multi block CBC is that flipped cipher text bits are not propagated to flipped plaintext bits in the next block.
@advanced_1239_p
@advanced_1240_p
Database encryption is meant for securing the database while it is not in use (stolen laptop and so on). It is not meant for cases where the attacker has access to files while the database is in use. When he has write access, he can for example replace pieces of files with pieces of older versions and manipulate data like this.
@advanced_1240_p
@advanced_1241_p
File encryption slows down the performance of the database engine. Compared to unencrypted mode, database operations take about 2.2 times longer when using XTEA, and 2.5 times longer using AES (embedded mode).
@advanced_1241_h3
@advanced_1242_h3
SSL/TLS Connections
@advanced_1242_p
@advanced_1243_p
Remote SSL/TLS connections are supported using the Java Secure Socket Extension (SSLServerSocket / SSLSocket). By default, anonymous SSL is enabled. The default cipher suite is <code>SSL_DH_anon_WITH_RC4_128_MD5</code> .
@advanced_1243_h3
@advanced_1244_h3
HTTPS Connections
@advanced_1244_p
@advanced_1245_p
The web server supports HTTP and HTTPS connections using SSLServerSocket. There is a default self-certified certificate to support an easy starting point, but custom certificates are supported as well.
@advanced_1245_h2
@advanced_1246_h2
Universally Unique Identifiers (UUID)
@advanced_1246_p
@advanced_1247_p
This database supports the UUIDs. Also supported is a function to create new UUIDs using a cryptographically strong pseudo random number generator. With random UUIDs, the chance of two having the same value can be calculated using the probability theory. See also 'Birthday Paradox'. Standardized randomly generated UUIDs have 122 random bits. 4 bits are used for the version (Randomly generated UUID), and 2 bits for the variant (Leach-Salz). 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:
@advanced_1247_p
@advanced_1248_p
Some values are:
@advanced_1248_p
@advanced_1249_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.
@advanced_1249_h2
@advanced_1250_h2
Settings Read from System Properties
@advanced_1250_p
@advanced_1251_p
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:
@advanced_1251_p
@advanced_1252_p
The current value of the settings can be read in the table INFORMATION_SCHEMA.SETTINGS.
@advanced_1252_p
@advanced_1253_p
For a complete list of settings, see <a href="../javadoc/org/h2/constant/SysProperties.html">SysProperties</a> .
@advanced_1253_h2
@advanced_1254_h2
Setting the Server Bind Address
@advanced_1254_p
@advanced_1255_p
Usually server sockets accept connections on any/all local addresses. This may be a problem on multi-homed hosts. To bind only to one address, use the system property h2.bindAddress. This setting is used for both regular server sockets and for SSL server sockets. IPv4 and IPv6 address formats are supported.
@advanced_1255_h2
@advanced_1256_h2
Glossary and Links
@advanced_1256_th
@advanced_1257_th
Term
@advanced_1257_th
@advanced_1258_th
Description
@advanced_1258_td
@advanced_1259_td
AES-128
@advanced_1259_td
@advanced_1260_td
A block encryption algorithm. See also: <a href="http://en.wikipedia.org/wiki/Advanced_Encryption_Standard">Wikipedia: AES</a>
@advanced_1260_td
@advanced_1261_td
Birthday Paradox
@advanced_1261_td
@advanced_1262_td
Describes the higher than expected probability that two persons in a room have the same birthday. Also valid for randomly generated UUIDs. See also: <a href="http://en.wikipedia.org/wiki/Birthday_paradox">Wikipedia: Birthday Paradox</a>
@advanced_1262_td
@advanced_1263_td
Digest
@advanced_1263_td
@advanced_1264_td
Protocol to protect a password (but not to protect data). See also: <a href="http://www.faqs.org/rfcs/rfc2617.html">RFC 2617: HTTP Digest Access Authentication</a>
@advanced_1264_td
@advanced_1265_td
GCJ
@advanced_1265_td
@advanced_1266_td
GNU Compiler for Java. <a href="http://gcc.gnu.org/java/">http://gcc.gnu.org/java/</a> and <a href="http://nativej.mtsystems.ch">http://nativej.mtsystems.ch/ (not free any more)</a>
@advanced_1266_td
@advanced_1267_td
HTTPS
@advanced_1267_td
@advanced_1268_td
A protocol to provide security to HTTP connections. See also: <a href="http://www.ietf.org/rfc/rfc2818.txt">RFC 2818: HTTP Over TLS</a>
@advanced_1268_td
@advanced_1269_td
Modes of Operation
@advanced_1269_a
@advanced_1270_a
Wikipedia: Block cipher modes of operation
@advanced_1270_td
@advanced_1271_td
Salt
@advanced_1271_td
@advanced_1272_td
Random number to increase the security of passwords. See also: <a href="http://en.wikipedia.org/wiki/Key_derivation_function">Wikipedia: Key derivation function</a>
@advanced_1272_td
@advanced_1273_td
SHA-256
@advanced_1273_td
@advanced_1274_td
A cryptographic one-way hash function. See also: <a href="http://en.wikipedia.org/wiki/SHA_family">Wikipedia: SHA hash functions</a>
@advanced_1274_td
@advanced_1275_td
SQL Injection
@advanced_1275_td
@advanced_1276_td
A security vulnerability where an application generates SQL statements with embedded user input. See also: <a href="http://en.wikipedia.org/wiki/SQL_injection">Wikipedia: SQL Injection</a>
@advanced_1276_td
@advanced_1277_td
Watermark Attack
@advanced_1277_td
@advanced_1278_td
Security problem of certain encryption programs where the existence of certain data can be proven without decrypting. For more information, search in the internet for 'watermark attack cryptoloop'
@advanced_1278_td
@advanced_1279_td
SSL/TLS
@advanced_1279_td
@advanced_1280_td
Secure Sockets Layer / Transport Layer Security. See also: <a href="http://java.sun.com/products/jsse/">Java Secure Socket Extension (JSSE)</a>
@advanced_1280_td
@advanced_1281_td
XTEA
@advanced_1281_td
@advanced_1282_td
A block encryption algorithm. See also: <a href="http://en.wikipedia.org/wiki/XTEA">Wikipedia: XTEA</a>
@build_1000_h1
......@@ -956,729 +959,732 @@ Change Log
Next Version (unreleased)
@changelog_1002_li
-
The performance of text comparison has been improved when using locale sensitive string comparison (SET COLLATOR). Now CollationKey is used with a LRU cache. The default cache size is 10000, and can be changed using the system property h2.collatorCacheSize. Use 0 to disable the cache.
@changelog_1003_h2
Version 1.0.67 (2008-02-22)
@changelog_1003_li
UPDATE SET column=DEFAULT is now supported.
@changelog_1004_li
New function FILE_READ to read a file or from an URL. Both binary and text data is supported.
@changelog_1004_h2
Version 1.0.67 (2008-02-22)
@changelog_1005_li
CREATE TABLE AS SELECT now supports specifying the column list and data types.
New function FILE_READ to read a file or from an URL. Both binary and text data is supported.
@changelog_1006_li
Connecting to a TCP server and at shutting it down at the same time could cause a Java level deadlock.
CREATE TABLE AS SELECT now supports specifying the column list and data types.
@changelog_1007_li
A user now has all rights on his own local temporary tables.
Connecting to a TCP server and at shutting it down at the same time could cause a Java level deadlock.
@changelog_1008_li
The CSV tool now supports a custom lineSeparator.
A user now has all rights on his own local temporary tables.
@changelog_1009_li
When using multiple connections, empty space was reused too early sometimes. This was sometimes causing database corruption.
The CSV tool now supports a custom lineSeparator.
@changelog_1010_li
The H2 Console has been translated to Dutch. Thanks a lot to Remco Schoen!
When using multiple connections, empty space was reused too early sometimes. This could corrupt the database when recovering.
@changelog_1011_li
Databases can now be opened even if trigger classes are not in the classpath. The exception is thrown when trying to fire the trigger.
The H2 Console has been translated to Dutch. Thanks a lot to Remco Schoen!
@changelog_1012_li
Opening databases with ACCESS_MODE_DATA=r is now supported. In this case the database is read-only, but the files don't not need to be read-only.
Databases can now be opened even if trigger classes are not in the classpath. The exception is thrown when trying to fire the trigger.
@changelog_1013_li
Security: The database now waits 200 ms before throwing an exception if the user name or password don't match, to slow down dictionary attacks.
Opening databases with ACCESS_MODE_DATA=r is now supported. In this case the database is read-only, but the files don't not need to be read-only.
@changelog_1014_li
The value cache is now a soft reference cache. This should help save memory.
Security: The database now waits 200 ms before throwing an exception if the user name or password don't match, to slow down dictionary attacks.
@changelog_1015_li
CREATE INDEX on a table with many rows could run out of memory. Fixed.
The value cache is now a soft reference cache. This should help save memory.
@changelog_1016_li
Large result sets are now a bit faster.
CREATE INDEX on a table with many rows could run out of memory. Fixed.
@changelog_1017_li
ALTER TABLE ALTER COLUMN RESTART and ALTER SEQUENCE now support parameters (any expressions).
Large result sets are now a bit faster.
@changelog_1018_li
When setting the base directory on the command line, the user directory prefix ('~') was ignored.
ALTER TABLE ALTER COLUMN RESTART and ALTER SEQUENCE now support parameters (any expressions).
@changelog_1019_li
The DbStarter servlet didn't start the TCP listener even if configured.
When setting the base directory on the command line, the user directory prefix ('~') was ignored.
@changelog_1020_li
Statement.setQueryTimeout() is now supported.
The DbStarter servlet didn't start the TCP listener even if configured.
@changelog_1021_li
New session setting QUERY_TIMEOUT, and new system property h2.maxQueryTimeout.
Statement.setQueryTimeout() is now supported.
@changelog_1022_li
Changing the transaction log level (SET LOG) is now written to the trace file by default.
New session setting QUERY_TIMEOUT, and new system property h2.maxQueryTimeout.
@changelog_1023_li
In a SQL script, primary key constraints are now ordered before foreign key constraints.
Changing the transaction log level (SET LOG) is now written to the trace file by default.
@changelog_1024_li
It was not possible to create a referential constraint to a table in a different schema in some situations.
In a SQL script, primary key constraints are now ordered before foreign key constraints.
@changelog_1025_li
It was not possible to create a referential constraint to a table in a different schema in some situations.
@changelog_1026_li
The H2 Console was slow when the database contains many tables. Now the column names are not shown in this case.
@changelog_1026_h2
@changelog_1027_h2
Version 1.0.66 (2008-02-02)
@changelog_1027_li
@changelog_1028_li
There is a new online error analyzer tool.
@changelog_1028_li
@changelog_1029_li
H2 Console: stack traces are now links to the source code in the source repository (H2 database only).
@changelog_1029_li
@changelog_1030_li
CHAR data type equals comparison was case insensitive instead of case sensitive.
@changelog_1030_li
@changelog_1031_li
The exception 'Value too long for column' now includes the data.
@changelog_1031_li
@changelog_1032_li
The table name was missing in the documentation of CREATE INDEX.
@changelog_1032_li
@changelog_1033_li
Better support for IKVM (www.ikvm.net): the H2 Console now opens a browser window.
@changelog_1033_li
@changelog_1034_li
The cache size was not correctly calculated for tables with large objects (specially if compression is used). This could lead to out-of-memory exceptions.
@changelog_1034_li
@changelog_1035_li
The exception "Hexadecimal string contains non-hex character" was not always thrown when it should have been. Fixed.
@changelog_1035_li
@changelog_1036_li
The H2 Console now provides a link to the documentation when an error occurs (H2 databases only so far).
@changelog_1036_li
@changelog_1037_li
The acting as PostgreSQL server, when a base directory was set, and the H2 Console was started as well, the base directory was applied twice.
@changelog_1037_li
@changelog_1038_li
Calling EXTRACT(HOUR FROM ...) or EXTRACT(HH FROM ...) returned the wrong values (0 to 11 instead of 0 to 23). All other tested databases return values from 0 to 23. Please check if your application relies on the old behavior before upgrading.
@changelog_1038_li
@changelog_1039_li
For compatibility with other databases the column default (COLUMN_DEF) for columns without default is now null (it was an empty string).
@changelog_1039_li
@changelog_1040_li
Statements that contain very large subqueries (where the subquery result does not fit in memory) are now faster.
@changelog_1040_li
@changelog_1041_li
Variables: large objects (CLOB and BLOB) that don't fit in memory did not work correctly when used as variables.
@changelog_1041_li
@changelog_1042_li
Fulltext search is now supported in named in-memory databases.
@changelog_1042_li
@changelog_1043_li
H2 Console: multiple consecutive spaces in the setting name did not work. Fixed.
@changelog_1043_h2
@changelog_1044_h2
Version 1.0.65 (2008-01-18)
@changelog_1044_li
@changelog_1045_li
The build (ant) now automatically switches the source code to the correct version (JDK 1.4/1.5 or 1.6).
@changelog_1045_li
@changelog_1046_li
A recovery bug has been fixed. With older versions, it was necessary to add ;RECOVER=1 to the database URL in cases where it should not have been required.
@changelog_1046_li
@changelog_1047_li
The performance for DROP and DROP ALL OBJECTS has been improved.
@changelog_1047_li
@changelog_1048_li
The ChangePassword API has been improved.
@changelog_1048_li
@changelog_1049_li
User defined variables are now supported. Examples: SET @VAR=10;CALL @VAR. This can be used for running totals as in: select x, set(@t, ifnull(@t, 0) + x) from system_range(1, 10)
@changelog_1049_li
@changelog_1050_li
The Ukrainian translation has been improved.
@changelog_1050_li
@changelog_1051_li
CALL statements can now be used in batch updates and called using Statement.executeUpdate.
@changelog_1051_li
@changelog_1052_li
New read-only setting CREATE_BUILD (the build number of the database engine that created the database).
@changelog_1052_li
@changelog_1053_li
The optimizer did not use multi column indexes for range queries in some cases. Fixed.
@changelog_1053_li
@changelog_1054_li
The H2 Console now calls DataSource.getConnection() instead of DataSource.getConnection(user, password) when user name and password are not specified.
@changelog_1054_li
@changelog_1055_li
The bind IP address can now be set when using multi-homed host (if multiple network adapters are available) using the system property h2.bindAddress.
@changelog_1055_li
@changelog_1056_li
Batch update: Calling BatchUpdateException.printStackTrace() could result in out of memory. Fixed.
@changelog_1056_li
@changelog_1057_li
Indexes of unique or foreign constraints where not dropped when the constraint was dropped after altering the table (for example dropping a column). Fixed.
@changelog_1057_li
@changelog_1058_li
The performance for large result sets in the server mode has been improved.
@changelog_1058_li
@changelog_1059_li
The setting h2.serverSmallResultSetSize has been renamed to h2.serverResultSetFetchSize.
@changelog_1059_li
@changelog_1060_li
The SCRIPT command now uses multi-row insert statements to save space except if the option SIMPLE is used.
@changelog_1060_li
@changelog_1061_li
The SCRIPT command did not split up CLOB data correctly. Fixed.
@changelog_1061_li
@changelog_1062_li
Optimization for single column distinct queries with an index: select distinct name from test. Can be disabled by setting the system property h2.optimizeDistinct to false.
@changelog_1062_li
@changelog_1063_li
DROP ALL OBJECTS did not drop user defined aggregate functions and domains.
@changelog_1063_li
@changelog_1064_li
PostgreSQL compatibility: COUNT(T.*) is now supported.
@changelog_1064_li
@changelog_1065_li
LIKE comparisons are now faster.
@changelog_1065_li
@changelog_1066_li
Encrypted databases are now faster.
@changelog_1066_h2
@changelog_1067_h2
Version 1.0.64 (2007-12-27)
@changelog_1067_li
@changelog_1068_li
3-way union queries with prepared statement or views could return the wrong results. Fixed.
@changelog_1068_li
@changelog_1069_li
The PostgreSQL ODBC driver did not work in the last release due to a parser regression. Fixed.
@changelog_1069_li
@changelog_1070_li
CSV tool: some escape/separator character combinations did not work. Fixed.
@changelog_1070_li
@changelog_1071_li
CSV tool: the character # could not be used as a separator when reading.
@changelog_1071_li
@changelog_1072_li
Recovery: when the index file is corrupt, now the database deletes it and re-creates it automatically.
@changelog_1072_li
@changelog_1073_li
The MVCC mode did not work well with in-memory databases. Fixed.
@changelog_1073_li
@changelog_1074_li
The FTP server now supports a event listener. Thanks Fulvio Biondi for the help!
@changelog_1074_li
@changelog_1075_li
New system function CANCEL_SESSION to cancel the currently executing statement of another session.
@changelog_1075_li
@changelog_1076_li
The database now supports an exclusive mode. In exclusive mode, new connections are rejected.
@changelog_1076_li
@changelog_1077_li
H2 Console: when editing result sets, columns can now be set to null. The text 'null' must be escaped using '=null'.
@changelog_1077_li
@changelog_1078_li
New built-in functions RPAD and LPAD.
@changelog_1078_li
@changelog_1079_li
New meta data table INFORMATION_SCHEMA.SESSIONS and LOCKS to get information about active connections and locks. Admins will see all connections, non-admins only their own session.
@changelog_1079_li
@changelog_1080_li
The Ukrainian translation was not working in the last release. Fixed.
@changelog_1080_li
@changelog_1081_li
Creating many tables (many hundreds) was slow. Fixed.
@changelog_1081_li
@changelog_1082_li
Opening a database with many indexes (thousands) was slow. Fixed.
@changelog_1082_li
@changelog_1083_li
H2 Console / autocomplete: Ctrl+Space now shows the list in all modes.
@changelog_1083_li
@changelog_1084_li
The method Trigger.init has been changed: the parameters 'before' and 'type', have been added to the init method.
@changelog_1084_li
@changelog_1085_li
The performance has been improved for ResultSet methods with column name.
@changelog_1085_li
@changelog_1086_li
A stack trace was thrown if the system did not provide a quick secure random source and if there is no network or the network settings are not configured. Fixed.
@changelog_1086_li
@changelog_1087_li
The H2 Console has been translated to Turkish. Thanks a lot to Ridvan Agar!
@changelog_1087_li
@changelog_1088_li
Improved debugging support: toString methods of most object now return a meaningful text.
@changelog_1088_li
@changelog_1089_li
The classes DbStarter and WebServlet have been moved to src/main.
@changelog_1089_li
@changelog_1090_li
The column INFORMATION_SCHEMA.TRIGGERS.SQL now contains the CREATE TRIGGER statement.
@changelog_1090_li
@changelog_1091_li
Loading classes and calling methods can be restricted using the new system property h2.allowedClasses.
@changelog_1091_li
@changelog_1092_li
The database could not be used in Java applets due to security exceptions. Fixed.
@changelog_1092_h2
@changelog_1093_h2
Version 1.0.63 (2007-12-02)
@changelog_1093_li
@changelog_1094_li
The SecurePassword example has been improved.
@changelog_1094_li
@changelog_1095_li
In timezones where the summer time saving limit is at midnight, some dates do not work in some virtual machines, for example 2007-10-14 in Chile, using the Sun JVM 1.6.0_03-b05. Fixed.
@changelog_1095_li
@changelog_1096_li
The native fulltext search was not working properly after re-connecting.
@changelog_1096_li
@changelog_1097_li
Improved FTP server: now the PORT command is supported.
@changelog_1097_li
@changelog_1098_li
Temporary views (FROM(...)) with UNION didn't work if nested. Fixed.
@changelog_1098_li
@changelog_1099_li
Performance optimization for IN(...) and IN(SELECT...), currently disabled by default. To enable, use java -Dh2.optimizeInJoin=true
@changelog_1099_li
@changelog_1100_li
The H2 Console has been translated to Ukrainian by Igor Dobrovolskyi. Thanks a lot!
@changelog_1100_li
@changelog_1101_li
New function TABLE_DISTINCT.
@changelog_1101_li
@changelog_1102_li
Using LIMIT with values close to Integer.MAX_VALUE didn't work correctly.
@changelog_1102_li
@changelog_1103_li
Certain setting in the Server didn't work (http://code.google.com/p/h2database/issues/detail?id=7).
@changelog_1103_h2
@changelog_1104_h2
Version 1.0.62 (2007-11-25)
@changelog_1104_li
@changelog_1105_li
Large updates and deletes are now supported by buffering data to disk if required. The threshold is currently set to 100'000 bytes and can be changed using SET MAX_OPERATION_MEMORY or using by appending ;MAX_OPERATION_MEMORY=.. to the database URL. See also the docs.
@changelog_1105_li
@changelog_1106_li
MVCC: now an exception is thrown when an application tries to change the MVCC setting while the database is already open.
@changelog_1106_li
@changelog_1107_li
Referential integrity checks didn't lock the referenced table, and thus could read uncommitted rows of other connections. In that way the referential constraints could get violated (except when using MVCC).
@changelog_1107_li
@changelog_1108_li
Renaming or dropping a user with a schema, or removing the admin property of that user made the schema inaccessible after re-opening the database. Fixed.
@changelog_1108_li
@changelog_1109_li
The H2 Console now also support the command line option -ifExists when started from the Server tool, but only when connecting to H2 databases.
@changelog_1109_li
@changelog_1110_li
Duplicate column names were not detected when renaming columns. Fixed.
@changelog_1110_li
@changelog_1111_li
The console did not display multiple embedded spaces in text correctly. Fixed.
@changelog_1111_li
@changelog_1112_li
Google Android support: use 'ant codeswitchAndroid' to switch the source code to Android.
@changelog_1112_li
@changelog_1113_li
Values of type ARRAY are now sorted as in PostgreSQL.
@changelog_1113_li
@changelog_1114_li
In the cluster mode, could not connect if only one server was running (last release only). Fixed.
@changelog_1114_li
@changelog_1115_li
The performance of large CSV operations has been improved.
@changelog_1115_li
@changelog_1116_li
Now using custom toString() for most JDBC objects and commands.
@changelog_1116_li
@changelog_1117_li
Nested temporary views (SELECT * FROM (SELECT ...)) with parameters didn't work in some cases. Fixed.
@changelog_1117_li
@changelog_1118_li
CSV: Using an empty field delimiter didn't work (a workaround was using char(0)). Fixed.
@changelog_1118_li
@changelog_1119_li
A patch for Apache DDL Utils is available at https://issues.apache.org/jira/browse/DDLUTILS-185
@changelog_1119_li
@changelog_1120_li
The default value for h2.emergencySpaceInitial is now 256 KB (to speed up creating encrypted databases)
@changelog_1120_li
@changelog_1121_li
Eduardo Velasques has translated the H2 Console and the error messages to Brazilian Portuguese. Thanks a lot!
@changelog_1121_li
@changelog_1122_li
Creating a table from GROUP_CONCAT didn't work if the data was longer than 255 characters
@changelog_1122_h2
@changelog_1123_h2
Version 1.0.61 (2007-11-10)
@changelog_1123_li
@changelog_1124_li
The Lucene Fulltext implementation is now compiled and included in the h2.jar. Requires Lucene 2.2.
@changelog_1124_li
@changelog_1125_li
Added more tests. The code coverage is now at 83%.
@changelog_1125_li
@changelog_1126_li
ResultSetMetaData.getColumnDisplaySize was calculated as the longest display size for the given result set, but should be the maximum size that fits in the column. Fixed.
@changelog_1126_li
@changelog_1127_li
The MODE used to be a global setting, now it is a database level setting.
@changelog_1127_li
@changelog_1128_li
The database does now always round to the nearest number when converting a floating point to a integer: CAST(1.5 AS INT) will now result in 2, like in PostgreSQL and MySQL.
@changelog_1128_li
@changelog_1129_li
Math operations using unknown data types (for example -? and ?+?) are now interpreted as decimal.
@changelog_1129_li
@changelog_1130_li
INSTR, LOCATE: backward searching is not supported by using a negative start position.
@changelog_1130_li
@changelog_1131_li
Can now open a database stored in a jar or zip file (for example, jdbc:h2:zip:c:/temp/h2.zip!/test).
@changelog_1131_li
@changelog_1132_li
Files access now uses an API (FileSystem, FileObject), this will simplify adding other file systems and features (for example replication).
@changelog_1132_li
@changelog_1133_li
Vlad Alexahin has translated H2 Console to Russian. Thanks a lot!
@changelog_1133_li
@changelog_1134_li
Descending indexes are now supported. This is useful when sorting columns descending, for example by creation date.
@changelog_1134_li
@changelog_1135_li
Solved a Java level deadlock in the DatabaseCloser.
@changelog_1135_li
@changelog_1136_li
CREATE SEQUENCE: New option CACHE (number of pre-allocated numbers). New column CACHE in the sequence meta data table. The default cache size is still 32.
@changelog_1136_li
@changelog_1137_li
MVCC: The system property h2.mvcc has been removed. A few bugs have been fixed, and new tests have been added.
@changelog_1137_h2
@changelog_1138_h2
Version 1.0.60 (2007-10-20)
@changelog_1138_li
@changelog_1139_li
JdbcXAConnection: starting a transaction before getting the connection didn't switch off autocommit.
@changelog_1139_li
@changelog_1140_li
User defined aggregate functions are not supported.
@changelog_1140_li
@changelog_1141_li
Server.shutdownTcpServer was blocked when first called with force=false and then force=true. Now documentation is improved, and it is no longer blocked.
@changelog_1141_li
@changelog_1142_li
Stack traces did not include the SQL statement in all cases where they could have. Also, stack traces with SQL statement are now shorter.
@changelog_1142_li
@changelog_1143_li
Linked tables: now tables in non-default schemas are supported as well
@changelog_1143_li
@changelog_1144_li
New Italian translation from PierPaolo Ucchino. Thanks a lot!
@changelog_1144_li
@changelog_1145_li
CSV: New methods to set the escape character and field delimiter in the Csv tool and the CSVWRITE and CSVREAD methods.
@changelog_1145_li
@changelog_1146_li
Prepared statements could not be used after data definition statements (creating tables and so on). Fixed.
@changelog_1146_li
@changelog_1147_li
PreparedStatement.setMaxRows could not be changed to a higher value after the statement was executed.
@changelog_1147_li
@changelog_1148_li
The H2 Console could not connect twice to the same H2 embedded database at the same time. Fixed.
@changelog_1148_li
@changelog_1149_li
CSVREAD, RUNSCRIPT and so on now support URLs as well, using URL.openStream(). Example: select * from csvread('jar:file:///c:/temp/test.jar!/test.csv');
@changelog_1149_h2
@changelog_1150_h2
Version 1.0.59 (2007-10-03)
@changelog_1150_li
@changelog_1151_li
When the data type was unknown in a subquery, sometimes the wrong exception (ArrayIndexOutOfBounds) was thrown. Fixed.
@changelog_1151_li
@changelog_1152_li
If the process was killed while the database was running, sometimes the database could not be opened ('double allocation') except when the system property h2.check was set to false. Fixed.
@changelog_1152_li
@changelog_1153_li
Multi-threaded kernel (MULTI_THREADED=1): A synchronization problem has been fixed.
@changelog_1153_li
@changelog_1154_li
A PreparedStatement that was cancelled could not be reused. Fixed.
@changelog_1154_li
@changelog_1155_li
H2 Console: Progress information when logging into a H2 embedded database (useful when opening a database is slow).
@changelog_1155_li
@changelog_1156_li
When the database was closed while logging was disabled (LOG 0), re-opening the database was slow. Fixed.
@changelog_1156_li
@changelog_1157_li
Fulltext search is now documented (in the Tutorial).
@changelog_1157_li
@changelog_1158_li
The Console did not refresh the table list if the CREATE TABLE statement started with a comment. Fixed.
@changelog_1158_li
@changelog_1159_li
When creating a table using CREATE TABLE .. AS SELECT, the precision for some data types (for example VARCHAR) was set to the default precision. Fixed.
@changelog_1159_li
@changelog_1160_li
When using the (undocumented) in-memory file system (jdbc:h2:memFS:x or jdbc:h2:memLZF:x), and using multiple connections, a ConcurrentModificationException could occur. Fixed.
@changelog_1160_li
@changelog_1161_li
REGEXP compatibility: So far String.matches was used, but for compatibility with MySQL, now Matcher.find is used.
@changelog_1161_li
@changelog_1162_li
SCRIPT: the SQL statements in the result set now include the terminating semicolon as well. Simplifies copy and paste.
@changelog_1162_li
@changelog_1163_li
When using a subquery with group by as a table, some columns could not be used in the where condition in the outer query. Example: SELECT * FROM (SELECT ID, COUNT(*) C FROM TEST) WHERE C > 100. Fixed.
@changelog_1163_li
@changelog_1164_li
Views with subqueries as tables and queries with nested subqueries as tables did not always work. Fixed.
@changelog_1164_li
@changelog_1165_li
Compatibility: comparing columns with constants that are out of range does not throw an exception.
@changelog_1165_h2
@changelog_1166_h2
Version 1.0.58 (2007-09-15)
@changelog_1166_li
@changelog_1167_li
System.exit is no longer called by the WebServer, the Console and the Server tool (except to set the exit code if required). This is important when using OSGi.
@changelog_1167_li
@changelog_1168_li
Optimization for independent subqueries. For example, this query can now an index: SELECT * FROM TEST WHERE ID = (SELECT MAX(ID) FROM TEST) This can be disabled by setting the system property h2.optimizeSubqueryCache to false.
@changelog_1168_li
@changelog_1169_li
The explain plan now says: /* direct lookup query */ if the query can be processed directly without reading rows, for example when using MIN(indexed column), MAX(indexed column), or COUNT(*).
@changelog_1169_li
@changelog_1170_li
When using IFNULL, NULLIF, COALESCE, LEAST, or GREATEST, and the first parameter was ?, an exception was thrown. Now the highest data type of all parameters is used.
@changelog_1170_li
@changelog_1171_li
When comparing TINYINT or SMALLINT columns against constants, the index was not used. Fixed.
@changelog_1171_li
@changelog_1172_li
Maven 2: new version are now automatically synced with the central repositories.
@changelog_1172_li
@changelog_1173_li
The default value for MAX_MEMORY_UNDO is now 100000.
@changelog_1173_li
@changelog_1174_li
The documentation indexer does no longer index Japanese pages. If somebody knows how to split Japanese into words please post it.
@changelog_1174_li
@changelog_1175_li
Oracle compatibility: SYSDATE now returns a timestamp. CHR(..) is now an alias for CHAR(..).
@changelog_1175_li
@changelog_1176_li
After deleting data, empty space in the database files was not efficiently reused (but it was reused when opening the database). This has been fixed.
@changelog_1176_li
@changelog_1177_li
About 230 bytes per database was leaked. This is a problem for applications opening and closing many thousand databases. The main problem: a shutdown hook was added but never removed. Fixed. In JDK 1.4, there is an additionally problem, see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4197876. A workaround has been implemented.
@changelog_1177_li
@changelog_1178_li
Optimization for COLUMN IN(.., NULL) if the column does not allow NULL values.
@changelog_1178_li
@changelog_1179_li
Using spaces in column and table aliases was not supported when used inside a view or temporary view.
@changelog_1179_li
@changelog_1180_li
The version (build) number is now included in the manifest file.
@changelog_1180_li
@changelog_1181_li
In some systems, SecureRandom.generateSeed is very slow (taking one minute or more). For those cases, an alternative method is used that takes less than one second.
@changelog_1181_li
@changelog_1182_li
The database file sizes are now increased at most 32 MB at any time.
@changelog_1182_li
@changelog_1183_li
New method DatabaseEventListener.opened that is called just after opening a database.
@changelog_1183_li
@changelog_1184_li
When using the Console with Internet Explorer 6.0 or 7.0, a Javascript error was thrown after clearing the query.
@changelog_1184_li
@changelog_1185_li
A database can now be opened even if class of a user defined function is not in the classpath. Trying to call the function will throws an exception.
@changelog_1185_li
@changelog_1186_li
User defined functions and constants may not overload built-in functions and constants. This didn't work before, but now trying to create such an object will fail.
@changelog_1186_li
@changelog_1187_li
Improved MultiDimension tool (for spatial queries): in the last few releases the tool was actually slower than using a regular query (because index lookup got faster, and because the tool didn't support prepared statements) Now the tool generates prepared statements, and the performance is better again (about 5 times faster for a reasonable amount of data).
@changelog_1187_li
@changelog_1188_li
Adding a foreign key or when re-enabling referential integrity for a table failed when checking was enabled and the reference contained NULL.
@changelog_1188_li
@changelog_1189_li
For PgServer, character encoding other than UTF-8 did not work correctly. Fixed.
@changelog_1189_li
@changelog_1190_li
Using a function in a GROUP BY expression that is used in a view as a condition did not always work.
@changelog_1190_h2
@changelog_1191_h2
Version 1.0.57 (2007-08-25)
@changelog_1191_li
@changelog_1192_li
New experimental feature MVCC (multi version concurrency control). Can be set as a option when opening the database (jdbc:h2:test;MVCC=TRUE) or as a system property (-Dh2.mvcc=true). This is work-in-progress, use it at your own risk. Feedback is welcome.
@changelog_1192_li
@changelog_1193_li
The version number is now major.minor.micro where micro is the build number. Not all version are public, so there may be gaps in the micro. The minor changes when there is a file format change.
@changelog_1193_li
@changelog_1194_li
The backup tool (org.h2.tools.Backup) did not work. The restore tool did not work when the -db parameter was used. Fixed. The documentation of the backup tool has been changed: only one database may be backed up at any time.
@changelog_1194_li
@changelog_1195_li
Opening large read-only databases was very slow. Fixed.
@changelog_1195_li
@changelog_1196_li
New Japanese translation of the error messages thanks to Ikemoto Masahiro. Thanks a lot!
@changelog_1196_li
@changelog_1197_li
Disabling / enabling referential integrity for a table can now be used inside a transaction.
@changelog_1197_li
@changelog_1198_li
Rights checking for dynamic tables (SELECT * FROM (SELECT ...)) did not work. Fixed.
@changelog_1198_li
@changelog_1199_li
Creating more than 10 views that depend on each other was very slow. Reconnecting was slow as well. Fixed.
@changelog_1199_li
@changelog_1200_li
When used as as Servlet, the H2 Console did not work with SSL (using Tomcat). Fixed.
@changelog_1200_li
@changelog_1201_li
When altering a table with foreign key constraint, if there was no manual index created for the referenced columns, the automatically created index was dropped while still being used. Fixed.
@changelog_1201_li
@changelog_1202_li
Check and foreign key constraints now checks if the existing data is consistent (this can be disabled by appending NOCHECK). It is also possible to check existing data when re-enabling referential integrity for a table.
@changelog_1202_li
@changelog_1203_li
Some unit tests failed on Linux because the file system works differently. The unit tests are fixed and should work now.
@changelog_1203_li
@changelog_1204_li
Can now incrementally translate the documentation. See also FAQ.
@changelog_1204_li
@changelog_1205_li
Improved error messages: some tools can't show the root cause of an exception. Adding the message of the root cause to the message of the thrown exception now where it makes sense.
@changelog_1205_li
@changelog_1206_li
The H2 Console can now connect to databases using JNDI. The driver class name must be a javax.naming.Context, (for example javax.naming.InitialContext), and the URL the resource name (for example java:comp/env/jdbc/Test). This should also work for linked tables.
@changelog_1206_li
@changelog_1207_li
Google translate did not work for the H2 homepage. It should be fixed now.
@changelog_1207_li
@changelog_1208_li
The CONVERT function did not work with views when using UNION.
@changelog_1208_li
@changelog_1209_li
The build now issues a warning if the source code is switched to the wrong version.
@changelog_1209_li
@changelog_1210_li
The default lock mode is now read committed instead of serialized.
@changelog_1210_li
@changelog_1211_li
PG server: data was truncated when reading large VARCHAR columns and decimal columns.
@changelog_1211_li
@changelog_1212_li
PG server: when the same database was accessed multiple times using the PostgreSQL ODBC driver, the pg_catalog schema update failed, and connecting to the database was not possible. Fixed.
@changelog_1212_li
@changelog_1213_li
Some file operations didn't work for files in the root directory. Fixed.
@changelog_1213_li
@changelog_1214_li
In the Restore tool, the parameter -file did not work. Fixed.
@changelog_1214_li
@changelog_1215_li
Two-phase commit: commit with transaction name was only supported in the recovery scan. Now it is always supported.
@changelog_1215_li
@changelog_1216_li
The column name C_CURRENT_TIMESTAMP did not work in the last release.
@changelog_1216_li
@changelog_1217_li
OpenOffice compatibility: support database name in column names.
@changelog_1217_h2
@changelog_1218_h2
Version 1.0.56 (2007-08-02)
@changelog_1218_li
@changelog_1219_li
A new tool to help translation has been implemented: src/tools/org/h2/tools/i18n/PrepareTranslation. This tool can detect delta changes in the original (English) and prepends '#' in translation if the original text was changed. It can also extract text from the user documentation (however, it is incomplete).
@changelog_1219_li
@changelog_1220_li
The error messages (src/main/org/h2/res/_*.*) can now be translated.
@changelog_1220_li
@changelog_1221_li
Part of the documentation has been translated to Japanese by Yusuke Fukushima.
@changelog_1221_li
@changelog_1222_li
Some Unicode characters where not supported as identifier name. Thanks Yusuke Fukushima for reporting this problem.
@changelog_1222_li
@changelog_1223_li
The default value DEFAULT_MAX_LENGTH_INPLACE_LOB has been changed from 128 to 1024.
@changelog_1223_li
@changelog_1224_li
A server that implements the PostgreSQL protocol is now included and documented. That means, the PostgreSQL ODBC driver can be used to access a H2 database. See in the documentation for details.
@changelog_1224_li
@changelog_1225_li
The experimental H2 ODBC driver has been removed.
@changelog_1225_li
@changelog_1226_li
The default value for h2.defaultMaxMemoryUndo is now 50000. This avoids out of memory problems when using large transactions, however large transactions are slower because they are buffered to disk. To disable, use -Dh2.defaultMaxMemoryUndo=2000000000.
@changelog_1226_li
@changelog_1227_li
Support for regular expression function REGEXP_REPLACE(expression, regex, replacement) and regular expression LIKE: expression REGEXP matchExpression. However, indexes are not yet used.
@changelog_1227_li
@changelog_1228_li
The old view implementation has been removed.
@changelog_1228_li
@changelog_1229_li
The SysTray tool has been removed, because JDK 1.6 has native support for system tray icons. Use the Console tool (org.h2.tools.Console) automatically installs a system tray icon if JDK 1.6 is used.
@changelog_1229_li
@changelog_1230_li
H2 Console: In the last release, the shutdown button did not work. Fixed.
@changelog_1230_li
@changelog_1231_li
Referential integrity can now be disabled using SET REFERENTIAL_INTEGRITY FALSE. It can also be disable only for one table using ALTER TABLE SET REFERENTIAL_INTEGRITY FALSE.
@changelog_1231_li
@changelog_1232_li
The Backup and Restore tools, and the BACKUP command did not back up LOBs when h2.lobFilesInDirectories was enabled. Fixed.
@changelog_1232_li
@changelog_1233_li
Calculation of cache memory usage has been improved.
@changelog_1233_li
@changelog_1234_li
In some situations record were released too late from the cache. Fixed.
@changelog_1234_li
@changelog_1235_li
The cache size is now measured in KB instead of blocks of 128 byte.
@changelog_1235_li
@changelog_1236_li
CREATE TABLE ... AS SELECT now needs less memory. While inserting the rows, the undo log is temporarily disabled. This avoid out of memory problems when creating large tables.
@changelog_1236_li
@changelog_1237_li
The per session undo log can now be disabled. This setting is useful for bulk operations that don't need to be atomic, like bulk delete or update.
@changelog_1237_li
@changelog_1238_li
The database file could get corrupted when there was an OutOfMemoryException in the middle of inserting a row.
@changelog_1238_li
@changelog_1239_li
Optimization for WHERE NOT(...) and WHERE [NOT] booleanFlagColumn. This can be disabled using the system property h2.optimizeNot.
@changelog_1239_li
@changelog_1240_li
Optimization for conditions like WHERE A=B AND B=X (A=X is added). This often appears in joins. This can be disabled using the system property h2.optimizeTwoEquals.
@changelog_1240_li
@changelog_1241_li
Documentation: the source code in 'Compacting a Database' was incorrect. Fixed.
@changelog_1241_li
@changelog_1242_li
In the H2 Console, result sets could not be modified because the default result set type is now forward only. For H2, now uses scrollable result sets. Also for other databases, but only when the query starts with @EDIT.
@changelog_1242_li
@changelog_1243_li
Views using UNION did not work correctly. Fixed.
@changelog_1243_li
@changelog_1244_li
Function tables did not work with views and EXPLAIN. Fixed.
@download_1000_h1
......@@ -6556,282 +6562,279 @@ Additional database drivers can be registered by adding the Jar file location of
@tutorial_1056_p
Multiple drivers can be set; each entry needs to be separated with a ';' (Windows) or ':' (other operating systems). Spaces in the path names are supported. The settings must not be quoted.
@tutorial_1057_p
Only the Java version supports additional drivers (this feature is not supported by the Native version).
@tutorial_1058_h3
@tutorial_1057_h3
Using the Application
@tutorial_1059_p
@tutorial_1058_p
The application has three main panels, the toolbar on top, the tree on the left and the query / result panel on the right. The database objects (for example, tables) are listed on the left panel. Type in a SQL command on the query panel and click 'Run'. The result of the command appears just below the command.
@tutorial_1060_h3
@tutorial_1059_h3
Inserting Table Names or Column Names
@tutorial_1061_p
@tutorial_1060_p
The table name and column names can be inserted in the script by clicking them in the tree. If you click on a table while the query is empty, a 'SELECT * FROM ...' is added as well. While typing a query, the table that was used is automatically expanded in the tree. For, example if you type 'SELECT * FROM TEST T WHERE T.' then the table TEST is automatically expanded in the tree.
@tutorial_1062_h3
@tutorial_1061_h3
Disconnecting and Stopping the Application
@tutorial_1063_p
@tutorial_1062_p
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.
@tutorial_1064_p
@tutorial_1063_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), press [Ctrl]+[C] on the console where the server was started (Windows), or close the console window.
@tutorial_1065_h2
@tutorial_1064_h2
Connecting to a Database using JDBC
@tutorial_1066_p
@tutorial_1065_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:
@tutorial_1067_p
@tutorial_1066_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. The database URL always needs to start with <code>jdbc:h2:</code> to be recognized by this database. The second parameter in the <code>getConnection()</code> call is the user name ('sa' for System Administrator in this example). The third parameter is the password. Please note that in this database, user names are not case sensitive, but passwords are case sensitive.
@tutorial_1068_h2
@tutorial_1067_h2
Creating New Databases
@tutorial_1069_p
@tutorial_1068_p
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.
@tutorial_1070_h2
@tutorial_1069_h2
Using the Server
@tutorial_1071_p
@tutorial_1070_p
H2 currently supports three servers: a Web Server, a TCP Server and an ODBC Server. The servers can be started in different ways.
@tutorial_1072_h3
@tutorial_1071_h3
Starting the Server from Command Line
@tutorial_1073_p
@tutorial_1072_p
To start the Server from the command line with the default settings, run
@tutorial_1074_p
@tutorial_1073_p
This will start the Server with the default options. To get the list of options and default values, run
@tutorial_1075_p
@tutorial_1074_p
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.
@tutorial_1076_h3
@tutorial_1075_h3
Connecting to the TCP Server
@tutorial_1077_p
@tutorial_1076_p
To remotly connect to a database using the TCP server, use the following driver and database URL:
@tutorial_1078_li
@tutorial_1077_li
JDBC driver class: org.h2.Driver
@tutorial_1079_li
@tutorial_1078_li
Database URL: jdbc:h2:tcp://localhost/~/test
@tutorial_1080_p
@tutorial_1079_p
For details about the database URL, see also in Features.
@tutorial_1081_h3
@tutorial_1080_h3
Starting the Server within an Application
@tutorial_1082_p
@tutorial_1081_p
It is also possible to start and stop a Server from within an application. Sample code:
@tutorial_1083_h3
@tutorial_1082_h3
Stopping a TCP Server from Another Process
@tutorial_1084_p
@tutorial_1083_p
The TCP Server can be stopped from another process. To stop the server from the command line, run:
@tutorial_1085_p
@tutorial_1084_p
To stop the server from a user application, use the following code:
@tutorial_1086_p
@tutorial_1085_p
This function will call System.exit on the server. 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.
@tutorial_1087_h3
@tutorial_1086_h3
Limitations of the Server
@tutorial_1088_p
@tutorial_1087_p
There currently are a few limitations when using the server or cluster mode:
@tutorial_1089_li
@tutorial_1088_li
Statement.cancel() is only supported in embedded mode. A connection can only execute one operation at a time in server or cluster mode, and is blocked until this operation is finished.
@tutorial_1090_h2
@tutorial_1089_h2
Using Hibernate
@tutorial_1091_p
@tutorial_1090_p
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.
@tutorial_1092_h2
@tutorial_1091_h2
Using Databases in Web Applications
@tutorial_1093_p
@tutorial_1092_p
There are multiple ways to access a database from within web applications. Here are some examples if you use Tomcat or JBoss.
@tutorial_1094_h3
@tutorial_1093_h3
Embedded Mode
@tutorial_1095_p
@tutorial_1094_p
The (currently) most simple solution is to use the database in the embedded mode, that means open a connection in your application when it starts (a good solution is using a Servlet Listener, see below), or when a session starts. A database can be accessed from multiple sessions and applications at the same time, as long as they run in the same process. Most Servlet Containers (for example Tomcat) are just using one process, so this is not a problem (unless you run Tomcat in clustered mode). Tomcat uses multiple threads and multiple classloaders. If multiple applications access the same database at the same time, you need to put the database jar in the shared/lib or server/lib directory. It is a good idea to open the database when the web application starts, and close it when the web applications stops. If using multiple applications, only one (any) of them needs to do that. In the application, an idea is to use one connection per Session, or even one connection per request (action). Those connections should be closed after use if possible (but it's not that bad if they don't get closed).
@tutorial_1096_h3
@tutorial_1095_h3
Server Mode
@tutorial_1097_p
@tutorial_1096_p
The server mode is similar, but it allows you to run the server in another process.
@tutorial_1098_h3
@tutorial_1097_h3
Using a Servlet Listener to Start and Stop a Database
@tutorial_1099_p
@tutorial_1098_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):
@tutorial_1100_p
@tutorial_1099_p
For details on how to access the database, see the code DbStarter.java
@tutorial_1101_h2
@tutorial_1100_h2
CSV (Comma Separated Values) Support
@tutorial_1102_p
@tutorial_1101_p
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.
@tutorial_1103_h3
@tutorial_1102_h3
Writing a CSV File from Within a Database
@tutorial_1104_p
@tutorial_1103_p
The built-in function CSVWRITE can be used to create a CSV file from a query. Example:
@tutorial_1105_h3
@tutorial_1104_h3
Reading a CSV File from Within a Database
@tutorial_1106_p
@tutorial_1105_p
A CSV file can be read using the function CSVREAD. Example:
@tutorial_1107_h3
@tutorial_1106_h3
Writing a CSV File from a Java Application
@tutorial_1108_p
@tutorial_1107_p
The CSV tool can be used in a Java application even when not using a database at all. Example:
@tutorial_1109_h3
@tutorial_1108_h3
Reading a CSV File from a Java Application
@tutorial_1110_p
@tutorial_1109_p
It is possible to read a CSV file without opening a database. Example:
@tutorial_1111_h2
@tutorial_1110_h2
Upgrade, Backup, and Restore
@tutorial_1112_h3
@tutorial_1111_h3
Database Upgrade
@tutorial_1113_p
@tutorial_1112_p
The recommended way to upgrade from one version of the database engine to the next version is to create a backup of the database (in the form of a SQL script) using the old engine, and then execute the SQL script using the new engine.
@tutorial_1114_h3
@tutorial_1113_h3
Backup using the Script Tool
@tutorial_1115_p
@tutorial_1114_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. This can be done using the Script tool:
@tutorial_1116_p
@tutorial_1115_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. The built in FTP server could be used to retrieve the file from the server.
@tutorial_1117_h3
@tutorial_1116_h3
Restore from a Script
@tutorial_1118_p
@tutorial_1117_p
To restore a database from a SQL script file, you can use the RunScript tool:
@tutorial_1119_p
@tutorial_1118_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. It is also possible to use the SQL command RUNSCRIPT to execute a SQL script. SQL script files may contain references to other script files, in the form of RUNSCRIPT commands. However, when using the server mode, the references script files need to be available on the server side.
@tutorial_1120_h3
@tutorial_1119_h3
Online Backup
@tutorial_1121_p
@tutorial_1120_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. 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:
@tutorial_1122_p
@tutorial_1121_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.
@tutorial_1123_h2
@tutorial_1122_h2
Using OpenOffice Base
@tutorial_1124_p
@tutorial_1123_p
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:
@tutorial_1125_li
@tutorial_1124_li
Stop OpenOffice, including the autostart
@tutorial_1126_li
@tutorial_1125_li
Copy h2.jar into the directory &lt;OpenOffice&gt;\program\classes
@tutorial_1127_li
@tutorial_1126_li
Start OpenOffice Base
@tutorial_1128_li
@tutorial_1127_li
Connect to an existing database, select JDBC, [Next]
@tutorial_1129_li
@tutorial_1128_li
Example datasource URL: jdbc:h2:c:/temp/test
@tutorial_1130_li
@tutorial_1129_li
JDBC driver class: org.h2.Driver
@tutorial_1131_p
@tutorial_1130_p
Now you can access the database stored in the directory C:/temp.
@tutorial_1132_h2
@tutorial_1131_h2
Java Web Start / JNLP
@tutorial_1133_p
@tutorial_1132_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 exception will occur: java.security.AccessControlException: access denied (java.io.FilePermission ... read). Example permission tags:
@tutorial_1134_h2
@tutorial_1133_h2
Fulltext Search
@tutorial_1135_p
@tutorial_1134_p
H2 supports Lucene full text search and native full text search implementation.
@tutorial_1136_h3
@tutorial_1135_h3
Using the Native Full Text Search
@tutorial_1137_p
@tutorial_1136_p
To initialize, call:
@tutorial_1138_p
@tutorial_1137_p
You need to initialize it in each database where you want to use it. Afterwards, you can create a full text index for a table using:
@tutorial_1139_p
@tutorial_1138_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. To search the index, use the following query:
@tutorial_1140_p
@tutorial_1139_p
You can also call the index from within a Java application:
@tutorial_1141_h3
@tutorial_1140_h3
Using the Lucene Fulltext Search
@tutorial_1142_p
@tutorial_1141_p
To use the Lucene full text search, you need the Lucene library in the classpath. How his is done depends on the application; if you use the H2 Console, you can add the Lucene jar file to the the environment variables H2DRIVERS or CLASSPATH. To initialize the Lucene full text search in a database, call:
@tutorial_1143_p
@tutorial_1142_p
You need to initialize it in each database where you want to use it. Afterwards, you can create a full text index for a table using:
@tutorial_1144_p
@tutorial_1143_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. To search the index, use the following query:
@tutorial_1145_p
@tutorial_1144_p
You can also call the index from within a Java application:
@tutorial_1146_h2
@tutorial_1145_h2
User Defined Variables
@tutorial_1147_p
@tutorial_1146_p
This database supports user defined variables. Variables start with @ and can be used whereever expressions or parameters are used. Variables not persisted and session scoped, that means only visible for the session where they are defined. A value is usually assigned using the SET command:
@tutorial_1148_p
@tutorial_1147_p
It is also possible to change a value using the SET() method. This is useful in queries:
@tutorial_1149_p
@tutorial_1148_p
Variables that are not set evaluate to NULL. The data type of a user defined variable is the data type of the value assigned to it, that means it is not necessary (or possible) to declare variable names before using them. There are no restrictions on the assigned values, large objects (LOBs) are supported as well.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -90,7 +90,7 @@ public class RuleElement implements Rule {
return null;
} else {
query = link.matchRemove(query, sentence);
if (query != null && !name.startsWith("@") && (link.name() == null || !link.name().startsWith("@"))) {
if (query != null && name != null && !name.startsWith("@") && (link.name() == null || !link.name().startsWith("@"))) {
while (query.length() > 0 && Character.isWhitespace(query.charAt(0))) {
query = query.substring(1);
}
......
......@@ -197,7 +197,7 @@ public class CreateTable extends SchemaCommand {
}
int scale = expr.getScale();
if (scale > 0 && (dt.defaultScale == 0 || dt.defaultScale > scale)) {
precision = dt.defaultScale;
scale = dt.defaultScale;
}
Column col = new Column(name, type, precision, scale, displaySize);
addColumn(col);
......
......@@ -61,8 +61,8 @@ public class SelectUnion extends Query {
orderList = order;
}
private Value[] convert(Value[] values) throws SQLException {
for (int i = 0; i < values.length; i++) {
private Value[] convert(Value[] values, int columnCount) throws SQLException {
for (int i = 0; i < columnCount; i++) {
Expression e = (Expression) expressions.get(i);
values[i] = values[i].convertTo(e.getType());
}
......@@ -116,19 +116,19 @@ public class SelectUnion extends Query {
case UNION_ALL:
case UNION: {
while (l.next()) {
result.addRow(convert(l.currentRow()));
result.addRow(convert(l.currentRow(), columnCount));
}
while (r.next()) {
result.addRow(convert(r.currentRow()));
result.addRow(convert(r.currentRow(), columnCount));
}
break;
}
case EXCEPT: {
while (l.next()) {
result.addRow(convert(l.currentRow()));
result.addRow(convert(l.currentRow(), columnCount));
}
while (r.next()) {
result.removeDistinct(convert(r.currentRow()));
result.removeDistinct(convert(r.currentRow(), columnCount));
}
break;
}
......@@ -136,10 +136,10 @@ public class SelectUnion extends Query {
LocalResult temp = new LocalResult(session, expressions, columnCount);
temp.setDistinct();
while (l.next()) {
temp.addRow(convert(l.currentRow()));
temp.addRow(convert(l.currentRow(), columnCount));
}
while (r.next()) {
Value[] values = convert(r.currentRow());
Value[] values = convert(r.currentRow(), columnCount);
if (temp.containsDistinct(values)) {
result.addRow(values);
}
......
......@@ -160,6 +160,7 @@ public class SysProperties {
* System property <code>h2.lobFilesInDirectories</code> (default: false).<br />
* Store LOB files in subdirectories.
*/
// TODO change in version 1.1
// TODO: also remove DataHandler.allocateObjectId, createTempFile when setting this to true and removing it
public static final boolean LOB_FILES_IN_DIRECTORIES = getBooleanSetting("h2.lobFilesInDirectories", false);
......@@ -252,6 +253,7 @@ public class SysProperties {
* System property <code>h2.optimizeInJoin</code> (default: false).<br />
* Optimize IN(...) comparisons by converting them to inner joins.
*/
// TODO change in version 1.1
public static final boolean OPTIMIZE_IN_JOIN = getBooleanSetting("h2.optimizeInJoin", false);
/**
......
......@@ -261,7 +261,11 @@ public class ConnectionInfo {
}
public String getProperty(String key) {
return prop.getProperty(key);
Object value = prop.get(key);
if (value == null || !(value instanceof String)) {
return null;
}
return value.toString();
}
public String getProperty(String key, String defaultValue) {
......
......@@ -146,6 +146,7 @@ public class Database implements DataHandler {
private boolean multiVersion;
private DatabaseCloser closeOnExit;
private Mode mode = Mode.getInstance(Mode.REGULAR);
// TODO change in version 1.1
private boolean multiThreaded;
private int maxOperationMemory = SysProperties.DEFAULT_MAX_OPERATION_MEMORY;
......
......@@ -993,8 +993,11 @@ public class Function extends Expression implements FunctionCall {
String fieldSeparatorRead = v3 == null ? null : v3.getString();
String fieldDelimiter = v4 == null ? null : v4.getString();
String escapeCharacter = v5 == null ? null : v5.getString();
Value v6 = getNullOrValue(session, args, 6);
String nullString = v6 == null ? null : v6.getString();
Csv csv = Csv.getInstance();
setCsvDelimiterEscape(csv, fieldSeparatorRead, fieldDelimiter, escapeCharacter);
csv.setNullString(nullString);
char fieldSeparator = csv.getFieldSeparatorRead();
String[] columns = StringUtils.arraySplit(columnList, fieldSeparator, true);
ValueResultSet vr = ValueResultSet.get(csv.read(fileName, columns, charset));
......@@ -1017,9 +1020,12 @@ public class Function extends Expression implements FunctionCall {
String fieldDelimiter = v4 == null ? null : v4.getString();
String escapeCharacter = v5 == null ? null : v5.getString();
Value v6 = getNullOrValue(session, args, 6);
String lineSeparator = v6 == null ? null : v6.getString();
String nullString = v6 == null ? null : v6.getString();
Value v7 = getNullOrValue(session, args, 7);
String lineSeparator = v7 == null ? null : v7.getString();
Csv csv = Csv.getInstance();
setCsvDelimiterEscape(csv, fieldSeparatorWrite, fieldDelimiter, escapeCharacter);
csv.setNullString(nullString);
if (lineSeparator != null) {
csv.setLineSeparator(lineSeparator);
}
......
......@@ -26,6 +26,19 @@ import org.h2.value.ValueNull;
/**
* This is the most common type of index, a b tree index.
* The index structure is:
* <ul>
* <li>There is one {@link BtreeHead} that points to the root page.
* The head always stays where it is.
* </li><li>There is a number of {@link BtreePage}s. Each page is eighter
* a {@link BtreeNode} or a {@link BtreeLeaf}.
* </li><li>A node page links to other leaf pages or to node pages.
* Leaf pages don't point to other pages (but may have a parent).
* </li><li>The uppermost page is the root page. If pages
* are added or deleted, the root page may change.
* </li>
* </ul>
* Only the data of the indexed columns are stored in the index.
*/
public class BtreeIndex extends BaseIndex implements RecordReader {
......
......@@ -153,12 +153,14 @@ public class MultiVersionCursor implements Cursor {
}
}
if (compare > 0) {
onBase = true;
needNewBase = true;
return true;
}
if (!isDeleted) {
throw Message.getInternalError();
}
onBase = false;
needNewDelta = true;
return true;
}
......
......@@ -71,7 +71,7 @@
90048=Datenbank Datei Version wird nicht unterst\u00FCtzt oder ung\u00FCltiger Dateikopf in Datei {0}
90049=Verschl\u00FCsselungsfehler in Datei {0}
90050=Falsches Passwort Format, ben\u00F6tigt wird\: Datei-Passwort <Leerschlag> Benutzer-Passwort
90051=Befehl wurde abgebrochen
90051=Befehl wurde abgebrochen oder das Session-Timeout ist abgelaufen
90052=Unterabfrage gibt mehr als eine Feld zur\u00FCck
90053=Skalar-Unterabfrage enth\u00E4lt mehr als eine Zeile
90054=Ung\u00FCltige Verwendung der Aggregat Funktion {0}
......
......@@ -71,7 +71,7 @@
90048=Unsupported database file version or invalid file header in file {0}
90049=Encryption error in file {0}
90050=Wrong password format, must be\: file password <space> user password
90051=Statement was cancelled
90051=Statement was cancelled or the session timed out
90052=Subquery is not a single column query
90053=Scalar subquery contains more than one row
90054=Invalid use of aggregate function {0}
......
......@@ -71,7 +71,7 @@
90048=\u30D5\u30A1\u30A4\u30EB {0} \u306F\u3001\u672A\u30B5\u30DD\u30FC\u30C8\u306E\u30D0\u30FC\u30B8\u30E7\u30F3\u304B\u3001\u4E0D\u6B63\u306A\u30D5\u30A1\u30A4\u30EB\u30D8\u30C3\u30C0\u3092\u6301\u3064\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u30D5\u30A1\u30A4\u30EB\u3067\u3059
90049=\u30D5\u30A1\u30A4\u30EB {0} \u306E\u6697\u53F7\u5316\u30A8\u30E9\u30FC\u3067\u3059
90050=\u4E0D\u6B63\u306A\u30D1\u30B9\u30EF\u30FC\u30C9\u30D5\u30A9\u30FC\u30DE\u30C3\u30C8\u3067\u3059\u3002\u6B63\u3057\u304F\u306F\: \u30D5\u30A1\u30A4\u30EB\u30D1\u30B9\u30EF\u30FC\u30C9 <\u7A7A\u767D> \u30E6\u30FC\u30B6\u30D1\u30B9\u30EF\u30FC\u30C9
90051=\u30B9\u30C6\u30FC\u30C8\u30E1\u30F3\u30C8\u306F\u30AD\u30E3\u30F3\u30BB\u30EB\u3055\u308C\u307E\u3057\u305F
90051=\# \u30B9\u30C6\u30FC\u30C8\u30E1\u30F3\u30C8\u306F\u30AD\u30E3\u30F3\u30BB\u30EB\u3055\u308C\u307E\u3057\u305F
90052=\u30B5\u30D6\u30AF\u30A8\u30EA\u304C\u5358\u4E00\u5217\u306E\u30AF\u30A8\u30EA\u3067\u306F\u3042\u308A\u307E\u305B\u3093
90053=\u6570\u5024\u30B5\u30D6\u30AF\u30A8\u30EA\u304C\u8907\u6570\u306E\u884C\u3092\u542B\u3093\u3067\u3044\u307E\u3059
90054=\u96C6\u5408\u95A2\u6570 {0} \u306E\u4E0D\u6B63\u306A\u4F7F\u7528
......
......@@ -71,7 +71,7 @@
90048=Nieprawidlowa wersja pliku bazy danych lub nieprawidlowy naglowek pliku {0}
90049=Blad szyfowania pliku {0}
90050=Zly format hasla, powinno byc\: plik haslo <spacja> uzytkownik haslo
90051=Statement was cancelled
90051=Statement was cancelled or the session timed out
90052=Podzapytanie nie jest zapytaniem opartym o jedna kolumne
90053=Scalar subquery contains more than one row
90054=Nieprawidlowe uzycie funkcji agregujacej {0}
......
......@@ -71,7 +71,7 @@
90048=Vers\u00E3o do arquivo de base de dados n\u00E3o \u00E9 suportado, ou o cabe\u00E7alho do arquivo \u00E9 inv\u00E1lido, no arquivo {0}
90049=Erro de encripta\u00E7\u00E3o no arquivo {0}
90050=Erro no formato da senha, deveria ser\: arquivo de senha <espa\u00E7o> senha do usu\u00E1rio
90051=O Statement foi cancelado
90051=\#O Statement foi cancelado
90052=A Subquery n\u00E3o \u00E9 de coluna \u00FAnica
90053=A Subquery cont\u00E9m mais de uma linha
90054=Uso inv\u00E1lido da fun\u00E7\u00E3o {0} agregada
......
......@@ -2649,13 +2649,15 @@ CURRVAL('TEST_SEQ')
"
"Functions (System)","CSVREAD","
CSVREAD(fileNameString [, columnNamesString [, charsetString [, fieldSeparatorString [, fieldDelimiterString [, escapeCharacterString]]]]]): resultSet
CSVREAD(fileNameString [, columnNamesString [, charsetString [, fieldSeparatorString [, fieldDelimiterString
[, escapeCharacterString [, nullString]]]]]]): resultSet
","
Returns the result set of reading the CSV (comma separated values) file.
If the column names are specified (a comma separated list of column names),
those are used they are read from the file, otherwise (or if they are set to NULL) the first line
of the file is interpreted as the column names.
The default charset is the default value for this system, and the default field separator is a comma.
Missing unquoted values as well as data that matches the null string is parsed as NULL.
This function can be used like a table: SELECT * FROM CSVREAD(...).
Instead of a file, an URL may be used, for example jar:file:///c:/temp/example.zip!/org/example/nested.zip.
Admin rights are required to execute this command.
......@@ -2665,11 +2667,12 @@ CALL CSVREAD('test.csv')
"Functions (System)","CSVWRITE","
CSVWRITE(fileNameString, queryString [, charsetString [, fieldSeparatorString [, fieldDelimiterString
[, escapeCharacterString [, lineSeparatorString]]]]]): int
[, escapeCharacterString [, nullString [, lineSeparatorString]]]]]]): int
","
Writes a CSV (comma separated values).
The file is overwritten if it exists.
The default charset is the default value for this system, and the default field separator is a comma.
The null string is used when writing NULL (by default nothing is written when NULL appears).
The default line separator is the default value for this system ('line.separator' system property).
The returned value is the number or rows written.
Admin rights are required to execute this command.
......
......@@ -38,4 +38,8 @@ public class SimpleRowValue implements SearchRow {
data = v;
}
public String toString() {
return "( /* " + pos + " */ " + data.getSQL() + " )";
}
}
......@@ -217,7 +217,7 @@ public class TcpServer implements Service {
}
}
public synchronized void stop() {
public void stop() {
// TODO server: share code between web and tcp servers
// need to remove the server first, otherwise the connection is broken
// while the server is still registered in this map
......@@ -264,12 +264,14 @@ public class TcpServer implements Service {
}
if (shutdownMode == SHUTDOWN_NORMAL) {
server.stopManagementDb();
server.stop = true;
try {
Socket s = NetUtils.createLoopbackSocket(port, false);
s.close();
} catch (Exception e) {
// try to connect - so that accept returns
synchronized (TcpServer.class) {
server.stop = true;
try {
Socket s = NetUtils.createLoopbackSocket(port, false);
s.close();
} catch (Exception e) {
// try to connect - so that accept returns
}
}
} else if (shutdownMode == SHUTDOWN_FORCE) {
server.stop();
......
......@@ -374,6 +374,9 @@ public class DbContextRule implements Rule {
if (set != null && !set.contains(table)) {
continue;
}
if (table == null || table.columns == null) {
continue;
}
for (int j = 0; j < table.columns.length; j++) {
String name = StringUtils.toUpperEnglish(table.columns[j].name);
if (up.startsWith(name)) {
......
......@@ -4,14 +4,15 @@
*/
package org.h2.server.web;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.StringReader;
import java.io.StringWriter;
......@@ -47,6 +48,7 @@ import org.h2.engine.Constants;
import org.h2.jdbc.JdbcSQLException;
import org.h2.message.TraceSystem;
import org.h2.tools.SimpleResultSet;
import org.h2.util.IOUtils;
import org.h2.util.JdbcUtils;
import org.h2.util.MathUtils;
import org.h2.util.MemoryUtils;
......@@ -57,8 +59,7 @@ import org.h2.util.ScriptReader;
import org.h2.util.StringUtils;
/**
* For each request, an object of this class is created.
* Keep-alive is not supported at this time.
* For each connection to a session, an object of this class is created.
* This class is used by the H2 Console.
*/
class WebThread extends Thread implements DatabaseEventListener {
......@@ -68,6 +69,7 @@ class WebThread extends Thread implements DatabaseEventListener {
private Socket socket;
private InputStream input;
private OutputStream output;
private String ifModifiedSince;
private String mimeType;
private boolean cache;
......@@ -147,83 +149,21 @@ class WebThread extends Thread implements DatabaseEventListener {
public void run() {
try {
input = socket.getInputStream();
String head = readHeaderLine();
if (head.startsWith("GET ") || head.startsWith("POST ")) {
int begin = head.indexOf('/'), end = head.lastIndexOf(' ');
String file = head.substring(begin + 1, end).trim();
server.trace(head + ": " + file);
file = getAllowedFile(file);
attributes = new Properties();
int paramIndex = file.indexOf("?");
session = null;
if (paramIndex >= 0) {
String attrib = file.substring(paramIndex + 1);
parseAttributes(attrib);
String sessionId = attributes.getProperty("jsessionid");
file = file.substring(0, paramIndex);
session = server.getSession(sessionId);
}
parseHeader();
String hostAddr = socket.getInetAddress().getHostAddress();
file = processRequest(file, hostAddr);
if (file.length() == 0) {
// asynchronous request
return;
}
String message;
byte[] bytes;
if (cache && ifModifiedSince != null && ifModifiedSince.equals(server.getStartDateTime())) {
bytes = null;
message = "HTTP/1.1 304 Not Modified\n";
} else {
bytes = server.getFile(file);
if (bytes == null) {
message = "HTTP/1.0 404 Not Found\n";
bytes = StringUtils.utf8Encode("File not found: " + file);
} else {
if (session != null && file.endsWith(".jsp")) {
String page = StringUtils.utf8Decode(bytes);
page = PageParser.parse(server, page, session.map);
try {
bytes = StringUtils.utf8Encode(page);
} catch (SQLException e) {
server.traceError(e);
}
}
message = "HTTP/1.1 200 OK\n";
message += "Content-Type: " + mimeType + "\n";
if (!cache) {
message += "Cache-Control: no-cache\n";
} else {
message += "Cache-Control: max-age=10\n";
message += "Last-Modified: " + server.getStartDateTime() + "\n";
}
}
}
message += "\n";
server.trace(message);
DataOutputStream output = openOutput(message);
if (bytes != null) {
output.write(bytes);
input = new BufferedInputStream(socket.getInputStream());
output = new BufferedOutputStream(socket.getOutputStream());
while (true) {
if (!process()) {
break;
}
closeOutput(output);
return;
}
} catch (Exception e) {
} catch (IOException e) {
TraceSystem.traceThrowable(e);
} catch (SQLException e) {
TraceSystem.traceThrowable(e);
}
}
private DataOutputStream openOutput(String message) throws IOException {
DataOutputStream output = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream()));
output.write(message.getBytes());
return output;
}
private void closeOutput(DataOutputStream output) {
IOUtils.closeSilently(output);
IOUtils.closeSilently(input);
try {
output.close();
socket.close();
} catch (IOException e) {
// ignore
......@@ -232,6 +172,73 @@ class WebThread extends Thread implements DatabaseEventListener {
}
}
public boolean process() throws IOException, SQLException {
boolean keepAlive = false;
String head = readHeaderLine();
if (head.startsWith("GET ") || head.startsWith("POST ")) {
int begin = head.indexOf('/'), end = head.lastIndexOf(' ');
String file = head.substring(begin + 1, end).trim();
server.trace(head + ": " + file);
file = getAllowedFile(file);
attributes = new Properties();
int paramIndex = file.indexOf("?");
session = null;
if (paramIndex >= 0) {
String attrib = file.substring(paramIndex + 1);
parseAttributes(attrib);
String sessionId = attributes.getProperty("jsessionid");
file = file.substring(0, paramIndex);
session = server.getSession(sessionId);
}
keepAlive = parseHeader();
String hostAddr = socket.getInetAddress().getHostAddress();
file = processRequest(file, hostAddr);
if (file.length() == 0) {
// asynchronous request
return true;
}
String message;
byte[] bytes;
if (cache && ifModifiedSince != null && ifModifiedSince.equals(server.getStartDateTime())) {
bytes = null;
message = "HTTP/1.1 304 Not Modified\n";
} else {
bytes = server.getFile(file);
if (bytes == null) {
message = "HTTP/1.0 404 Not Found\n";
bytes = StringUtils.utf8Encode("File not found: " + file);
} else {
if (session != null && file.endsWith(".jsp")) {
String page = StringUtils.utf8Decode(bytes);
page = PageParser.parse(server, page, session.map);
try {
bytes = StringUtils.utf8Encode(page);
} catch (SQLException e) {
server.traceError(e);
}
}
message = "HTTP/1.1 200 OK\n";
message += "Content-Type: " + mimeType + "\n";
if (!cache) {
message += "Cache-Control: no-cache\n";
} else {
message += "Cache-Control: max-age=10\n";
message += "Last-Modified: " + server.getStartDateTime() + "\n";
}
message += "Content-Length: " + bytes.length + "\n";
}
}
message += "\n";
server.trace(message);
output.write(message.getBytes());
if (bytes != null) {
output.write(bytes);
}
output.flush();
}
return keepAlive;
}
protected String getComboBox(String[] elements, String selected) {
StringBuffer buff = new StringBuffer();
for (int i = 0; i < elements.length; i++) {
......@@ -280,7 +287,7 @@ class WebThread extends Thread implements DatabaseEventListener {
}
}
private void parseAttributes(String s) throws Exception {
private void parseAttributes(String s) throws SQLException {
server.trace("data=" + s);
while (s != null) {
int idx = s.indexOf('=');
......@@ -291,12 +298,12 @@ class WebThread extends Thread implements DatabaseEventListener {
String value;
if (idx >= 0) {
value = s.substring(0, idx);
s = s.substring(idx+1);
s = s.substring(idx + 1);
} else {
value = s;
}
// TODO compatibility problem with JDK 1.3
//String attr = URLDecoder.decode(value, "UTF-8");
// String attr = URLDecoder.decode(value, "UTF-8");
// String attr = URLDecoder.decode(value);
String attr = StringUtils.urlDecode(value);
attributes.put(property, attr);
......@@ -307,7 +314,8 @@ class WebThread extends Thread implements DatabaseEventListener {
server.trace(attributes.toString());
}
private void parseHeader() throws Exception {
private boolean parseHeader() throws IOException, SQLException {
boolean keepAlive = false;
server.trace("parseHeader");
int len = 0;
ifModifiedSince = null;
......@@ -320,6 +328,11 @@ class WebThread extends Thread implements DatabaseEventListener {
String lower = StringUtils.toLowerEnglish(line);
if (lower.startsWith("if-modified-since")) {
ifModifiedSince = line.substring(line.indexOf(':') + 1).trim();
} else if (lower.startsWith("connection")) {
String conn = line.substring(line.indexOf(':') + 1).trim();
if ("keep-alive".equals(conn)) {
keepAlive = true;
}
} else if (lower.startsWith("content-length")) {
len = Integer.parseInt(line.substring(line.indexOf(':') + 1).trim());
server.trace("len=" + len);
......@@ -363,6 +376,7 @@ class WebThread extends Thread implements DatabaseEventListener {
String s = new String(bytes);
parseAttributes(s);
}
return keepAlive;
}
String process(String file) {
......@@ -494,8 +508,8 @@ class WebThread extends Thread implements DatabaseEventListener {
}
private String admin() {
session.put("port", ""+server.getPort());
session.put("allowOthers", ""+server.getAllowOthers());
session.put("port", "" + server.getPort());
session.put("allowOthers", "" + server.getAllowOthers());
session.put("ssl", String.valueOf(server.getSSL()));
session.put("sessions", server.getSessions());
return "admin.jsp";
......@@ -828,7 +842,8 @@ class WebThread extends Thread implements DatabaseEventListener {
error += " " + se.getSQLState() + "/" + se.getErrorCode();
if (isH2) {
int code = se.getErrorCode();
error += " <a href=\"http://h2database.com/javadoc/org/h2/constant/ErrorCode.html#c" + code + "\">(${text.a.help})</a>";
error += " <a href=\"http://h2database.com/javadoc/org/h2/constant/ErrorCode.html#c" + code
+ "\">(${text.a.help})</a>";
}
}
error += "<span style=\"display: none;\" id=\"st" + id + "\"><br />" + stackTrace + "</span>";
......@@ -884,7 +899,7 @@ class WebThread extends Thread implements DatabaseEventListener {
}
private String formatAsError(String s) {
return "<div class=\"error\">"+s+"</div>";
return "<div class=\"error\">" + s + "</div>";
}
private String test() {
......@@ -924,11 +939,8 @@ class WebThread extends Thread implements DatabaseEventListener {
session.put("autoComplete", "1");
session.put("maxrows", "1000");
boolean thread = false;
if (socket != null
&& url.startsWith("jdbc:h2:")
&& !url.startsWith("jdbc:h2:tcp:")
&& !url.startsWith("jdbc:h2:ssl:")
&& !url.startsWith("jdbc:h2:mem:")) {
if (socket != null && url.startsWith("jdbc:h2:") && !url.startsWith("jdbc:h2:tcp:")
&& !url.startsWith("jdbc:h2:ssl:") && !url.startsWith("jdbc:h2:mem:")) {
thread = true;
}
if (!thread) {
......@@ -947,14 +959,13 @@ class WebThread extends Thread implements DatabaseEventListener {
}
}
class LoginTask implements Runnable, DatabaseEventListener {
private DataOutputStream output;
private PrintWriter writer;
private SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss.SSS");
LoginTask() throws IOException {
String message = "HTTP/1.1 200 OK\n";
message += "Content-Type: " + mimeType + "\n\n";
output = openOutput(message);
output.write(message.getBytes());
writer = new PrintWriter(output);
writer.println("<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"stylesheet.css\" /></head>");
writer.println("<body><h2>Opening Database</h2>URL: " + PageParser.escapeHtml(url) + "<br />");
......@@ -996,7 +1007,7 @@ class WebThread extends Thread implements DatabaseEventListener {
} else {
listenerLastState = state;
}
switch(state) {
switch (state) {
case DatabaseEventListener.STATE_BACKUP_FILE:
log("Backing up " + name + " " + (100L * x / max) + "%");
break;
......@@ -1033,15 +1044,22 @@ class WebThread extends Thread implements DatabaseEventListener {
session.put("user", user);
session.remove("error");
settingSave();
log("OK<script type=\"text/javascript\">top.location=\"frame.jsp?jsessionid=" +sessionId+ "\"</script></body></htm>");
log("OK<script type=\"text/javascript\">top.location=\"frame.jsp?jsessionid=" + sessionId
+ "\"</script></body></htm>");
// return "frame.jsp";
} catch (Exception e) {
session.put("error", getLoginError(e, isH2));
log("Error<script type=\"text/javascript\">top.location=\"index.jsp?jsessionid=" +sessionId+ "\"</script></body></html>");
log("Error<script type=\"text/javascript\">top.location=\"index.jsp?jsessionid=" + sessionId
+ "\"</script></body></html>");
// return "index.jsp";
}
synchronized (this) {
closeOutput(output);
IOUtils.closeSilently(output);
try {
socket.close();
} catch (IOException e) {
// ignore
}
output = null;
}
}
......@@ -1322,7 +1340,9 @@ class WebThread extends Thread implements DatabaseEventListener {
rs.addRow(new String[] { "meta.getCatalogTerm", "" + meta.getCatalogTerm() });
rs.addRow(new String[] { "meta.getDatabaseProductName", "" + meta.getDatabaseProductName() });
rs.addRow(new String[] { "meta.getDatabaseProductVersion", "" + meta.getDatabaseProductVersion() });
rs.addRow(new String[] { "meta.getDefaultTransactionIsolation", "" + meta.getDefaultTransactionIsolation() });
rs
.addRow(new String[] { "meta.getDefaultTransactionIsolation",
"" + meta.getDefaultTransactionIsolation() });
rs.addRow(new String[] { "meta.getDriverMajorVersion", "" + meta.getDriverMajorVersion() });
rs.addRow(new String[] { "meta.getDriverMinorVersion", "" + meta.getDriverMinorVersion() });
rs.addRow(new String[] { "meta.getDriverName", "" + meta.getDriverName() });
......@@ -1353,66 +1373,81 @@ class WebThread extends Thread implements DatabaseEventListener {
rs.addRow(new String[] { "meta.getProcedureTerm", "" + meta.getProcedureTerm() });
rs.addRow(new String[] { "meta.getSchemaTerm", "" + meta.getSchemaTerm() });
rs.addRow(new String[] { "meta.getSearchStringEscape", "" + meta.getSearchStringEscape() });
rs.addRow(new String[] { "meta.getSQLKeywords", "" + meta.getSQLKeywords()});
rs.addRow(new String[]{"meta.getStringFunctions", ""+meta.getStringFunctions()});
rs.addRow(new String[]{"meta.getSystemFunctions", ""+meta.getSystemFunctions()});
rs.addRow(new String[]{"meta.getTimeDateFunctions", ""+meta.getTimeDateFunctions()});
rs.addRow(new String[]{"meta.getURL", ""+meta.getURL()});
rs.addRow(new String[]{"meta.getUserName", ""+meta.getUserName()});
rs.addRow(new String[]{"meta.isCatalogAtStart", ""+meta.isCatalogAtStart()});
rs.addRow(new String[]{"meta.isReadOnly", ""+meta.isReadOnly()});
rs.addRow(new String[]{"meta.allProceduresAreCallable", ""+meta.allProceduresAreCallable()});
rs.addRow(new String[]{"meta.allTablesAreSelectable", ""+meta.allTablesAreSelectable()});
rs.addRow(new String[]{"meta.dataDefinitionCausesTransactionCommit", ""+meta.dataDefinitionCausesTransactionCommit()});
rs.addRow(new String[]{"meta.dataDefinitionIgnoredInTransactions", ""+meta.dataDefinitionIgnoredInTransactions()});
rs.addRow(new String[]{"meta.doesMaxRowSizeIncludeBlobs", ""+meta.doesMaxRowSizeIncludeBlobs()});
rs.addRow(new String[]{"meta.nullPlusNonNullIsNull", ""+meta.nullPlusNonNullIsNull()});
rs.addRow(new String[]{"meta.nullsAreSortedAtEnd", ""+meta.nullsAreSortedAtEnd()});
rs.addRow(new String[]{"meta.nullsAreSortedAtStart", ""+meta.nullsAreSortedAtStart()});
rs.addRow(new String[]{"meta.nullsAreSortedHigh", ""+meta.nullsAreSortedHigh()});
rs.addRow(new String[]{"meta.nullsAreSortedLow", ""+meta.nullsAreSortedLow()});
rs.addRow(new String[]{"meta.storesLowerCaseIdentifiers", ""+meta.storesLowerCaseIdentifiers()});
rs.addRow(new String[]{"meta.storesLowerCaseQuotedIdentifiers", ""+meta.storesLowerCaseQuotedIdentifiers()});
rs.addRow(new String[]{"meta.storesMixedCaseIdentifiers", ""+meta.storesMixedCaseIdentifiers()});
rs.addRow(new String[]{"meta.storesMixedCaseQuotedIdentifiers", ""+meta.storesMixedCaseQuotedIdentifiers()});
rs.addRow(new String[]{"meta.storesUpperCaseIdentifiers", ""+meta.storesUpperCaseIdentifiers()});
rs.addRow(new String[]{"meta.storesUpperCaseQuotedIdentifiers", ""+meta.storesUpperCaseQuotedIdentifiers()});
rs.addRow(new String[]{"meta.supportsAlterTableWithAddColumn", ""+meta.supportsAlterTableWithAddColumn()});
rs.addRow(new String[]{"meta.supportsAlterTableWithDropColumn", ""+meta.supportsAlterTableWithDropColumn()});
rs.addRow(new String[]{"meta.supportsANSI92EntryLevelSQL", ""+meta.supportsANSI92EntryLevelSQL()});
rs.addRow(new String[]{"meta.supportsANSI92FullSQL", ""+meta.supportsANSI92FullSQL()});
rs.addRow(new String[]{"meta.supportsANSI92IntermediateSQL", ""+meta.supportsANSI92IntermediateSQL()});
rs.addRow(new String[]{"meta.supportsBatchUpdates", ""+meta.supportsBatchUpdates()});
rs.addRow(new String[]{"meta.supportsCatalogsInDataManipulation", ""+meta.supportsCatalogsInDataManipulation()});
rs.addRow(new String[]{"meta.supportsCatalogsInIndexDefinitions", ""+meta.supportsCatalogsInIndexDefinitions()});
rs.addRow(new String[]{"meta.supportsCatalogsInPrivilegeDefinitions", ""+meta.supportsCatalogsInPrivilegeDefinitions()});
rs.addRow(new String[]{"meta.supportsCatalogsInProcedureCalls", ""+meta.supportsCatalogsInProcedureCalls()});
rs.addRow(new String[]{"meta.supportsCatalogsInTableDefinitions", ""+meta.supportsCatalogsInTableDefinitions()});
rs.addRow(new String[]{"meta.supportsColumnAliasing", ""+meta.supportsColumnAliasing()});
rs.addRow(new String[]{"meta.supportsConvert", ""+meta.supportsConvert()});
rs.addRow(new String[]{"meta.supportsCoreSQLGrammar", ""+meta.supportsCoreSQLGrammar()});
rs.addRow(new String[]{"meta.supportsCorrelatedSubqueries", ""+meta.supportsCorrelatedSubqueries()});
rs.addRow(new String[]{"meta.supportsDataDefinitionAndDataManipulationTransactions", ""+meta.supportsDataDefinitionAndDataManipulationTransactions()});
rs.addRow(new String[]{"meta.supportsDataManipulationTransactionsOnly", ""+meta.supportsDataManipulationTransactionsOnly()});
rs.addRow(new String[]{"meta.supportsDifferentTableCorrelationNames", ""+meta.supportsDifferentTableCorrelationNames()});
rs.addRow(new String[]{"meta.supportsExpressionsInOrderBy", ""+meta.supportsExpressionsInOrderBy()});
rs.addRow(new String[]{"meta.supportsExtendedSQLGrammar", ""+meta.supportsExtendedSQLGrammar()});
rs.addRow(new String[]{"meta.supportsFullOuterJoins", ""+meta.supportsFullOuterJoins()});
rs.addRow(new String[]{"meta.supportsGroupBy", ""+meta.supportsGroupBy()});
rs.addRow(new String[] { "meta.getSQLKeywords", "" + meta.getSQLKeywords() });
rs.addRow(new String[] { "meta.getStringFunctions", "" + meta.getStringFunctions() });
rs.addRow(new String[] { "meta.getSystemFunctions", "" + meta.getSystemFunctions() });
rs.addRow(new String[] { "meta.getTimeDateFunctions", "" + meta.getTimeDateFunctions() });
rs.addRow(new String[] { "meta.getURL", "" + meta.getURL() });
rs.addRow(new String[] { "meta.getUserName", "" + meta.getUserName() });
rs.addRow(new String[] { "meta.isCatalogAtStart", "" + meta.isCatalogAtStart() });
rs.addRow(new String[] { "meta.isReadOnly", "" + meta.isReadOnly() });
rs.addRow(new String[] { "meta.allProceduresAreCallable", "" + meta.allProceduresAreCallable() });
rs.addRow(new String[] { "meta.allTablesAreSelectable", "" + meta.allTablesAreSelectable() });
rs.addRow(new String[] { "meta.dataDefinitionCausesTransactionCommit",
"" + meta.dataDefinitionCausesTransactionCommit() });
rs.addRow(new String[] { "meta.dataDefinitionIgnoredInTransactions",
"" + meta.dataDefinitionIgnoredInTransactions() });
rs.addRow(new String[] { "meta.doesMaxRowSizeIncludeBlobs", "" + meta.doesMaxRowSizeIncludeBlobs() });
rs.addRow(new String[] { "meta.nullPlusNonNullIsNull", "" + meta.nullPlusNonNullIsNull() });
rs.addRow(new String[] { "meta.nullsAreSortedAtEnd", "" + meta.nullsAreSortedAtEnd() });
rs.addRow(new String[] { "meta.nullsAreSortedAtStart", "" + meta.nullsAreSortedAtStart() });
rs.addRow(new String[] { "meta.nullsAreSortedHigh", "" + meta.nullsAreSortedHigh() });
rs.addRow(new String[] { "meta.nullsAreSortedLow", "" + meta.nullsAreSortedLow() });
rs.addRow(new String[] { "meta.storesLowerCaseIdentifiers", "" + meta.storesLowerCaseIdentifiers() });
rs.addRow(new String[] { "meta.storesLowerCaseQuotedIdentifiers",
"" + meta.storesLowerCaseQuotedIdentifiers() });
rs.addRow(new String[] { "meta.storesMixedCaseIdentifiers", "" + meta.storesMixedCaseIdentifiers() });
rs.addRow(new String[] { "meta.storesMixedCaseQuotedIdentifiers",
"" + meta.storesMixedCaseQuotedIdentifiers() });
rs.addRow(new String[] { "meta.storesUpperCaseIdentifiers", "" + meta.storesUpperCaseIdentifiers() });
rs.addRow(new String[] { "meta.storesUpperCaseQuotedIdentifiers",
"" + meta.storesUpperCaseQuotedIdentifiers() });
rs.addRow(new String[] { "meta.supportsAlterTableWithAddColumn",
"" + meta.supportsAlterTableWithAddColumn() });
rs.addRow(new String[] { "meta.supportsAlterTableWithDropColumn",
"" + meta.supportsAlterTableWithDropColumn() });
rs.addRow(new String[] { "meta.supportsANSI92EntryLevelSQL", "" + meta.supportsANSI92EntryLevelSQL() });
rs.addRow(new String[] { "meta.supportsANSI92FullSQL", "" + meta.supportsANSI92FullSQL() });
rs.addRow(new String[] { "meta.supportsANSI92IntermediateSQL", "" + meta.supportsANSI92IntermediateSQL() });
rs.addRow(new String[] { "meta.supportsBatchUpdates", "" + meta.supportsBatchUpdates() });
rs.addRow(new String[] { "meta.supportsCatalogsInDataManipulation",
"" + meta.supportsCatalogsInDataManipulation() });
rs.addRow(new String[] { "meta.supportsCatalogsInIndexDefinitions",
"" + meta.supportsCatalogsInIndexDefinitions() });
rs.addRow(new String[] { "meta.supportsCatalogsInPrivilegeDefinitions",
"" + meta.supportsCatalogsInPrivilegeDefinitions() });
rs.addRow(new String[] { "meta.supportsCatalogsInProcedureCalls",
"" + meta.supportsCatalogsInProcedureCalls() });
rs.addRow(new String[] { "meta.supportsCatalogsInTableDefinitions",
"" + meta.supportsCatalogsInTableDefinitions() });
rs.addRow(new String[] { "meta.supportsColumnAliasing", "" + meta.supportsColumnAliasing() });
rs.addRow(new String[] { "meta.supportsConvert", "" + meta.supportsConvert() });
rs.addRow(new String[] { "meta.supportsCoreSQLGrammar", "" + meta.supportsCoreSQLGrammar() });
rs.addRow(new String[] { "meta.supportsCorrelatedSubqueries", "" + meta.supportsCorrelatedSubqueries() });
rs.addRow(new String[] { "meta.supportsDataDefinitionAndDataManipulationTransactions",
"" + meta.supportsDataDefinitionAndDataManipulationTransactions() });
rs.addRow(new String[] { "meta.supportsDataManipulationTransactionsOnly",
"" + meta.supportsDataManipulationTransactionsOnly() });
rs.addRow(new String[] { "meta.supportsDifferentTableCorrelationNames",
"" + meta.supportsDifferentTableCorrelationNames() });
rs.addRow(new String[] { "meta.supportsExpressionsInOrderBy", "" + meta.supportsExpressionsInOrderBy() });
rs.addRow(new String[] { "meta.supportsExtendedSQLGrammar", "" + meta.supportsExtendedSQLGrammar() });
rs.addRow(new String[] { "meta.supportsFullOuterJoins", "" + meta.supportsFullOuterJoins() });
rs.addRow(new String[] { "meta.supportsGroupBy", "" + meta.supportsGroupBy() });
// TODO meta data: more supports methods (I'm tired now)
rs.addRow(new String[]{"meta.usesLocalFilePerTable", ""+meta.usesLocalFilePerTable()});
rs.addRow(new String[]{"meta.usesLocalFiles", ""+meta.usesLocalFiles()});
//#ifdef JDK14
rs.addRow(new String[]{"conn.getHoldability", ""+conn.getHoldability()});
rs.addRow(new String[]{"meta.getDatabaseMajorVersion", ""+meta.getDatabaseMajorVersion()});
rs.addRow(new String[]{"meta.getDatabaseMinorVersion", ""+meta.getDatabaseMinorVersion()});
rs.addRow(new String[]{"meta.getJDBCMajorVersion", ""+meta.getJDBCMajorVersion()});
rs.addRow(new String[]{"meta.getJDBCMinorVersion", ""+meta.getJDBCMinorVersion()});
rs.addRow(new String[]{"meta.getResultSetHoldability", ""+meta.getResultSetHoldability()});
rs.addRow(new String[]{"meta.getSQLStateType", ""+meta.getSQLStateType()});
rs.addRow(new String[]{"meta.supportsGetGeneratedKeys", ""+meta.supportsGetGeneratedKeys()});
rs.addRow(new String[]{"meta.locatorsUpdateCopy", ""+meta.locatorsUpdateCopy()});
//#endif
rs.addRow(new String[] { "meta.usesLocalFilePerTable", "" + meta.usesLocalFilePerTable() });
rs.addRow(new String[] { "meta.usesLocalFiles", "" + meta.usesLocalFiles() });
// #ifdef JDK14
rs.addRow(new String[] { "conn.getHoldability", "" + conn.getHoldability() });
rs.addRow(new String[] { "meta.getDatabaseMajorVersion", "" + meta.getDatabaseMajorVersion() });
rs.addRow(new String[] { "meta.getDatabaseMinorVersion", "" + meta.getDatabaseMinorVersion() });
rs.addRow(new String[] { "meta.getJDBCMajorVersion", "" + meta.getJDBCMajorVersion() });
rs.addRow(new String[] { "meta.getJDBCMinorVersion", "" + meta.getJDBCMinorVersion() });
rs.addRow(new String[] { "meta.getResultSetHoldability", "" + meta.getResultSetHoldability() });
rs.addRow(new String[] { "meta.getSQLStateType", "" + meta.getSQLStateType() });
rs.addRow(new String[] { "meta.supportsGetGeneratedKeys", "" + meta.supportsGetGeneratedKeys() });
rs.addRow(new String[] { "meta.locatorsUpdateCopy", "" + meta.locatorsUpdateCopy() });
// #endif
return rs;
} else if (sql.startsWith("@CATALOGS")) {
return meta.getCatalogs();
......@@ -1456,7 +1491,7 @@ class WebThread extends Thread implements DatabaseEventListener {
return meta.getUDTs(p[1], p[2], p[3], types);
} else if (sql.startsWith("@TYPE_INFO")) {
return meta.getTypeInfo();
//#ifdef JDK14
// #ifdef JDK14
} else if (sql.startsWith("@SUPER_TYPES")) {
String[] p = split(sql);
return meta.getSuperTypes(p[1], p[2], p[3]);
......@@ -1466,7 +1501,7 @@ class WebThread extends Thread implements DatabaseEventListener {
} else if (sql.startsWith("@ATTRIBUTES")) {
String[] p = split(sql);
return meta.getAttributes(p[1], p[2], p[3], p[4]);
//#endif
// #endif
}
return null;
}
......@@ -1560,9 +1595,9 @@ class WebThread extends Thread implements DatabaseEventListener {
session.addCommand(sql);
if (generatedKeys) {
rs = null;
//#ifdef JDK14
// #ifdef JDK14
rs = stat.getGeneratedKeys();
//#endif
// #endif
} else {
if (!isResultSet) {
buff.append("${text.result.updateCount}: " + stat.getUpdateCount());
......@@ -1578,11 +1613,11 @@ class WebThread extends Thread implements DatabaseEventListener {
}
time = System.currentTimeMillis() - time;
buff.append(getResultSet(sql, rs, metadata, list, edit, time, allowEdit));
// SQLWarning warning = stat.getWarnings();
// if(warning != null) {
// buff.append("<br />Warning:<br />");
// buff.append(getStackTrace(id, warning));
// }
// SQLWarning warning = stat.getWarnings();
// if(warning != null) {
// buff.append("<br />Warning:<br />");
// buff.append(getStackTrace(id, warning));
// }
if (!edit) {
stat.close();
}
......@@ -1697,7 +1732,8 @@ class WebThread extends Thread implements DatabaseEventListener {
buff.append("<tr><td>");
buff.append("<a href=\"getHistory.do?id=");
buff.append(i);
buff.append("&jsessionid=${sessionId}\" target=\"h2query\" ><img width=16 height=16 src=\"ico_write.gif\" onmouseover = \"this.className ='icon_hover'\" onmouseout = \"this.className ='icon'\" class=\"icon\" alt=\"${text.resultEdit.edit}\" title=\"${text.resultEdit.edit}\" border=\"1\"/></a>");
buff
.append("&jsessionid=${sessionId}\" target=\"h2query\" ><img width=16 height=16 src=\"ico_write.gif\" onmouseover = \"this.className ='icon_hover'\" onmouseout = \"this.className ='icon'\" class=\"icon\" alt=\"${text.resultEdit.edit}\" title=\"${text.resultEdit.edit}\" border=\"1\"/></a>");
buff.append("</td><td>");
buff.append(PageParser.escapeHtml(sql));
buff.append("</td></tr>");
......@@ -1707,7 +1743,8 @@ class WebThread extends Thread implements DatabaseEventListener {
return buff.toString();
}
private String getResultSet(String sql, ResultSet rs, boolean metadata, boolean list, boolean edit, long time, boolean allowEdit) throws SQLException {
private String getResultSet(String sql, ResultSet rs, boolean metadata, boolean list, boolean edit, long time,
boolean allowEdit) throws SQLException {
int maxrows = getMaxrows();
time = System.currentTimeMillis() - time;
StringBuffer buff = new StringBuffer();
......@@ -1795,10 +1832,12 @@ class WebThread extends Thread implements DatabaseEventListener {
buff.append("<img onclick=\"javascript:editRow(");
buff.append(rs.getRow());
buff.append(",'${sessionId}', '${text.resultEdit.save}', '${text.resultEdit.cancel}'");
buff.append(")\" width=16 height=16 src=\"ico_write.gif\" onmouseover = \"this.className ='icon_hover'\" onmouseout = \"this.className ='icon'\" class=\"icon\" alt=\"${text.resultEdit.edit}\" title=\"${text.resultEdit.edit}\" border=\"1\"/>");
buff
.append(")\" width=16 height=16 src=\"ico_write.gif\" onmouseover = \"this.className ='icon_hover'\" onmouseout = \"this.className ='icon'\" class=\"icon\" alt=\"${text.resultEdit.edit}\" title=\"${text.resultEdit.edit}\" border=\"1\"/>");
buff.append("<a href=\"editResult.do?op=2&row=");
buff.append(rs.getRow());
buff.append("&jsessionid=${sessionId}\" target=\"h2result\" ><img width=16 height=16 src=\"ico_remove.gif\" onmouseover = \"this.className ='icon_hover'\" onmouseout = \"this.className ='icon'\" class=\"icon\" alt=\"${text.resultEdit.delete}\" title=\"${text.resultEdit.delete}\" border=\"1\" /></a>");
buff
.append("&jsessionid=${sessionId}\" target=\"h2result\" ><img width=16 height=16 src=\"ico_remove.gif\" onmouseover = \"this.className ='icon_hover'\" onmouseout = \"this.className ='icon'\" class=\"icon\" alt=\"${text.resultEdit.delete}\" title=\"${text.resultEdit.delete}\" border=\"1\" /></a>");
buff.append("</td>");
}
for (int i = 0; i < columns; i++) {
......@@ -1951,7 +1990,7 @@ class WebThread extends Thread implements DatabaseEventListener {
} else {
listenerLastState = state;
}
switch(state) {
switch (state) {
case DatabaseEventListener.STATE_BACKUP_FILE:
log("Backing up " + name + " " + (100L * x / max) + "%");
break;
......
......@@ -31,7 +31,6 @@ adminTitle=H2 Console Optionen
helpAction=Aktion
helpAddAnotherRow=F&uuml;gt einen weiteren Datensatz hinzu
helpAddDrivers=Datenbank Treiber hinzuf&uuml;gen
helpAddDriversOnlyJava=Zus&auml;tzliche Treiber werden nur von der Java Version unterst&uuml;tzt (nicht von der Native Version).
helpAddDriversText=Es ist m&ouml;glich zus&auml;tzliche Datenbank-Treiber zu laden, indem die Pfade der Treiber-Dateien in den Umgebungsvariablen H2DRIVERS oder CLASSPATH eingetragen werden. Beispiel (Windows)\: Um den Datenbank-Treiber mit dem Jar-File C\:\\Programs\\hsqldb\\lib\\hsqldb.jar hinzuzuf&uuml;gen, setzen Sie den die Umgebungvariable H2DRIVERS auf C\:\\Programs\\hsqldb\\lib\\hsqldb.jar.
helpAddRow=F&uuml;gt einen Datensatz hinzu
helpCommandHistory=Zeigt die Befehls-Chronik
......
......@@ -31,7 +31,6 @@ adminTitle=H2 Console Preferences
helpAction=Action
helpAddAnotherRow=Add another row
helpAddDrivers=Adding Database Drivers
helpAddDriversOnlyJava=Only the Java version supports additional drivers (this feature is not supported by the Native version).
helpAddDriversText=Additional database drivers can be registered by adding the Jar file location of the driver to the 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 C\:\\Programs\\hsqldb\\lib\\hsqldb.jar.
helpAddRow=Add a new row
helpCommandHistory=Shows the Command History
......
......@@ -31,7 +31,6 @@ adminTitle=Preferencias de H2 Consola
helpAction=Action
helpAddAnotherRow=A&ntilde;adir otra fila
helpAddDrivers=A&ntilde;adiendo drivers de base de datos
helpAddDriversOnlyJava=Solo la versi&oacute;n Java soporta otros drivers (esta caracteristica no esta soportada por la versi&oacute;n nativa).
helpAddDriversText=Se pueden registrar otros drivers a&ntilde;adiendo el archivo Jar del driver a la variable de entorno H2DRIVERS o CLASSPATH. Por ejemplo (Windows)\: Para a&ntilde;adir la librer&iacute;a del driver de base de datos C\:\\Programs\\hsqldb\\lib\\hsqldb.jar, hay que establecer la variable de entorno H2DRIVERS a C\:\\Programs\\hsqldb\\lib\\hsqldb.jar.
helpAddRow=A&ntilde;adir una fila nueva
helpCommandHistory=Ver hist&oacute;rico de comandos
......
......@@ -31,7 +31,6 @@ adminTitle=Console H2 de param&eacute;trage des options
helpAction=Action
helpAddAnotherRow=Ajouter un autre enregistrement
helpAddDrivers=Ajouter de drivers de base de donn&eacute;es
helpAddDriversOnlyJava=Seule la version Java permet d'ajouter des drivers suppl&eacute;mentaires. (Cette fonctionnalit&eacute; n'est pas support&eacute;e dans la version Native).
helpAddDriversText=Des drivers additionels peuvent &ecirc;tre configur&eacute;s en d&eacute;clarant l'emplacement du fichier Jar contenant ces drivers dans les variables d'environnement H2DRIVERS ou CLASSPATH. Exemple (Windows)\: Pour ajouter la librairie C\:\\Programs\\hsqldb\\lib\\hsqldb.jar, d&eacute;finir la valeur de la variable d'environnement H2DRIVERS en C\:\\Programs\\hsqldb\\lib\\hsqldb.jar.
helpAddRow=Ajouter un nouvel enregistrement
helpCommandHistory=Affiche l'historique des commandes
......
......@@ -31,8 +31,7 @@ adminTitle=H2 Konzol tulajdons&aacute;gai
helpAction=Parancs
helpAddAnotherRow=Rekord hozz&aacute;ad&aacute;sa
helpAddDrivers=Adatb&aacute;zis-illeszt&\#337;programok hozz&aacute;ad&aacute;sa
helpAddDriversOnlyJava=Illeszt&\#337;programok hozz&aacute;ad&aacute;s&aacute;t csak a Java verzi&oacute; t&aacute;mogatja, a nat&iacute;v verzi&oacute; nem.
helpAddDriversText=Tov&aacute;bbi adatb&aacute;zis-illeszt&\#337;programok regisztr&aacute;l&aacute;sakor a H2DRIVERS vagy CLASSPATH k&ouml;rnyezeti v&aacute;ltoz&oacute;khoz kell adni a .jar illeszt&\#337;program-f&aacute;jlok el&eacute;r&eacute;si &uacute;tvonalait. P&eacute;ld&aacute;ul (Windows eset&eacute;n) a C\:\\Programs\\hsqldb\\lib\\hsqldb.jar illeszt&\#337;program regisztr&aacute;l&aacute;s&aacute;hoz a H2DRIVERS k&ouml;rnyezeti v&aacute;ltoz&oacute;nak az al&aacute;bbi &eacute;rt&eacute;k&eacute;t kell megadni\: C\:\\Programs\\hsqldb\\lib\\hsqldb.jar
helpAddDriversText=Tov&aacute;bbi adatb&aacute;zis-illeszt&\#337;programok regisztr&aacute;l&aacute;sakor a H2DRIVERS vagy CLASSPATH k&ouml;rnyezeti v&aacute;ltoz&oacute;khoz kell adni a .jar illeszt&\#337;program-f&aacute;jlok el&eacute;r&eacute;si &uacute;tvonalait. P&eacute;ld&aacute;ul (Windows eset&eacute;n) a C\:\\Programs\\hsqldb\\lib\\hsqldb.jar illeszt&\#337;program regisztr&aacute;l&aacute;s&aacute;hoz a H2DRIVERS k&ouml;rnyezeti v&aacute;ltoz&oacute;nak az al&aacute;bbi &eacute;rt&eacute;k&eacute;t kell megadni\: C\:\\Programs\\hsqldb\\lib\\hsqldb.jar
helpAddRow=Rekord hozz&aacute;ad&aacute;sa
helpCommandHistory=Kor&aacute;bbi utas&iacute;t&aacute;sok megjelen&iacute;t&eacute;se
helpCreateTable=&Uacute;j t&aacute;bla l&eacute;trehoz&aacute;sa
......@@ -69,7 +68,7 @@ result.autoCommitOff=Automatikus j&oacute;v&aacute;hagy&aacute;s kikapcsolva
result.autoCommitOn=Automatikus j&oacute;v&aacute;hagy&aacute;s bekapcsolva
result.maxrowsSet=Rekordok maxim&aacute;lis sz&aacute;ma be&aacute;ll&iacute;tva
result.noRows=nincs rekord
result.noRunningStatement=Utas&iacute;t&aacute;s jelenleg nincs folyamatban
result.noRunningStatement=Utas&iacute;t&aacute;s jelenleg nincs folyamatban
result.rows=rekordok
result.statementWasCancelled=Az utas&iacute;t&aacute;s v&eacute;grehajt&aacute;sa megszakadt
result.updateCount=Friss&iacute;t&eacute;s
......
......@@ -31,7 +31,6 @@ adminTitle=Pilihan di Konsol H2
helpAction=Aksi
helpAddAnotherRow=Menambah sebuah baris
helpAddDrivers=Menambah pengendali basis data
helpAddDriversOnlyJava=Hanya versi Java saja yang mendukung pengendali tambahan (fitur ini tidak didukung oleh versi Native).
helpAddDriversText=Pengendali basis data tambahan dapat didaftarkan dengan cara menambah lokasi file Jar dari si pengendali ke variabel lingkungan H2DRIVERS atau CLASSPATH. Contoh (Windows)\: Untuk menambah librari pengendali basis data C\:\\Programs\\hsqldb\\lib\\hsqldb.jar, atur variabel lingkungan H2DRIVERS menjadi C\:\\Programs\\hsqldb\\lib\\hsqldb.jar.
helpAddRow=Tambah sebuah baris baru
helpCommandHistory=Tampilkan sejarah perintah
......
......@@ -31,7 +31,6 @@ adminTitle=Pannello di controllo preferenze H2
helpAction=Azione
helpAddAnotherRow=Aggiunge un'altra riga
helpAddDrivers=Aggiunta di altri driver per l'accesso al database
helpAddDriversOnlyJava=Solo la versione Java supporta drivers aggiuntivi (questa caratteristica non e' supportata dalla versione Nativa).
helpAddDriversText=I drivers per il database possono essere inseriti aggiungendo la posizione del file Jar del driver stesso alle variabili di ambiente H2DRIVERS o CLASSPATH. Esempio (Windows)\: Per aggiungere alla libreria il drivers per il database C\:\\Programs\\hsqldb\\lib\\hsqldb.jar, basta modificare la variabile di ambiente H2DRIVERS in C\:\\Programs\\hsqldb\\lib\\hsqldb.jar.
helpAddRow=Aggiunge una nuova riga
helpCommandHistory=Mostra l'elenco dei comandi eseguiti
......
......@@ -31,7 +31,6 @@ adminTitle=H2\u30B3\u30F3\u30BD\u30FC\u30EB\u8A2D\u5B9A
helpAction=\u30A2\u30AF\u30B7\u30E7\u30F3
helpAddAnotherRow=\u5225\u306E\u884C\u3092\u8FFD\u52A0
helpAddDrivers=\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u30C9\u30E9\u30A4\u30D0\u306E\u8FFD\u52A0
helpAddDriversOnlyJava=\u8FFD\u52A0\u30C9\u30E9\u30A4\u30D0\u6A5F\u80FD\u306F\u3001Java\u7248\u306E\u307F\u3067\u4F7F\u7528\u3067\u304D\u307E\u3059 (\u30CD\u30A4\u30C6\u30A3\u30D6\u7248\u3067\u306F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u307E\u305B\u3093)\u3002
helpAddDriversText=\u8FFD\u52A0\u30C9\u30E9\u30A4\u30D0\u306F\u3001Jar\u30D5\u30A1\u30A4\u30EB\u306E\u5834\u6240\u3092\u74B0\u5883\u5909\u6570 H2DRIVERS\u3001\u307E\u305F\u306F CLASSPATH \u306B\u8FFD\u52A0\u3059\u308B\u3053\u3068\u3067\u767B\u9332\u3067\u304D\u307E\u3059\u3002\u4F8B (Windows)\: \u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u30C9\u30E9\u30A4\u30D0\u30E9\u30A4\u30D6\u30E9\u30EA C\:\\Programs\\hsqldb\\lib\\hsqldb.jar \u3092\u8FFD\u52A0\u3059\u308B\u306B\u306F\u3001\u74B0\u5883\u5909\u6570 H2DRIVERS \u306B\u3001C\:\\Programs\\hsqldb\\lib\\hsqldb.jar \u3092\u8A2D\u5B9A\u3057\u307E\u3059\u3002
helpAddRow=\u65B0\u3057\u3044\u884C\u3092\u8FFD\u52A0
helpCommandHistory=\u30B3\u30DE\u30F3\u30C9\u5C65\u6B74\u3092\u8868\u793A
......
......@@ -31,7 +31,6 @@ adminTitle=H2 Console instellingen
helpAction=Gebeurtenis
helpAddAnotherRow=Voeg nogmaals een nieuwe regel toe
helpAddDrivers=Toevoegen drivers voor een database
helpAddDriversOnlyJava=ALleen de Java-versie staat het toevoegen van extra drivers toe (deze mogelijkheid is niet ondersteund door de Native-version)
helpAddDriversText=Extra drivers voor een database kunnen worden geregistreerd door het toevoegen van het Jar-bestand van de driver aan de omgevingsvariabelen H2DRIVERS of CLASSPATH. Voorbeeld (Windows)\: om de driver bibliotheek C\:\\Programs\\hsqldb\\lib\\hsqldb.jar toe te voegen, moet de omgevingsvariabele H2DRIVERS op C\:\\Programs\\hsqldb\\lib\\hsqldb.jar gezet worden.
helpAddRow=Voeg een nieuwe regel toe
helpCommandHistory=Toont de geschiedenis van commando's
......
......@@ -31,7 +31,6 @@ adminTitle=Ustawienia konsoli H2
helpAction=Akcja
helpAddAnotherRow=Dodaj kolejny rekord
helpAddDrivers=Dodatkowe sterowniki baz danych
helpAddDriversOnlyJava=Tylko implementacja w Javie pozwala na dodawanie dodatkowych sterownik&oacute;w (nie wspierane przez wersje natywn&\#261;).
helpAddDriversText=Additional database drivers can be registerd by adding the Jar file location of the driver to the 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 C\:\\Programs\\hsqldb\\lib\\hsqldb.jar.
helpAddRow=Dodaj nowy rekord
helpCommandHistory=Pokazuje histori&\#281; komend
......@@ -94,7 +93,7 @@ toolbar.maxRows=Maksymalna ilo&\#347;&\#263; rekord&oacute;w
toolbar.refresh=Od&\#347;wie&\#380;
toolbar.rollback=Cofnij zmiany
toolbar.run=Wykonaj (Ctrl+Enter)
toolbar.sqlStatement=Zapytanie SQL
toolbar.sqlStatement=Zapytanie SQL
tree.admin=Administrator
tree.current=Bierz&\#261;ca warto&\#347;&\#263;
tree.hashed=Haszowany
......
......@@ -31,7 +31,6 @@ adminTitle=Configura&ccedil;&atilde;o do H2 Terminal
helpAction=A&ccedil;&atilde;o
helpAddAnotherRow=Adicionar outra linha
helpAddDrivers=Adicionar drivers de Base de Dados
helpAddDriversOnlyJava=Apenas a vers&atilde;o Java permite que sejam adicionados novos drivers (est&aacute; op&ccedil;&atilde;o n&atilde;o &eacute; suportada pela vers&atilde;o nativa)
helpAddDriversText=&Eacute; poss&iacute;vel registrar outros drivers, adicionando o arquivo JAR respectivo na vari&aacute;vel de ambiente H2DRIVERS ou CLASSPATH. Exemplo (Windows)\: Para adicionar o driver que est&aacute; em C\:\\Programs\\hsqldb\\lib\\hsqldb.jar altere o valor da vari&aacute;vel de ambiente H2DRIVERS para C\:\\Programs\\hsqldb\\lib\\hsqldb.jar.
helpAddRow=Adicionar uma linha nova
helpCommandHistory=Mostrar o hist&oacute;rico de comandos
......
......@@ -31,7 +31,6 @@ adminTitle=Preferencias da Consola H2
helpAction=Ac&ccedil;&atilde;o
helpAddAnotherRow=Adicionar outra linha
helpAddDrivers=Adicionar drivers de Base de Dados
helpAddDriversOnlyJava=Apenas a vers&atilde;o Java permite que sejam adicionados novos drivers (esta op&ccedil;&atilde;o n&atilde;o &eacute; suportado pela vers&atilde;o nativa)
helpAddDriversText=&Eacute; poss&iacute;vel registar outros drivers, adicionando o ficheiro JAR respectivo, &agrave; vari&aacute;vel de ambiente H2DRIVERS ou CLASSPATH. Exemplo (Windows)\: Para adicionar o driver que se encontra em C\:\\Programs\\hsqldb\\lib\\hsqldb.jar, alterar o valor da vari&aacute;vel de ambiente H2DRIVERS para C\:\\Programs\\hsqldb\\lib\\hsqldb.jar.
helpAddRow=Adicionar uma linha nova
helpCommandHistory=Mostrar o hist&oacute;rico de comandos
......
......@@ -31,7 +31,6 @@ adminTitle=H2 Console Preferences
helpAction=&\#1044;&\#1077;&\#1081;&\#1089;&\#1090;&\#1074;&\#1080;&\#1077;
helpAddAnotherRow=&\#1044;&\#1086;&\#1073;&\#1072;&\#1074;&\#1080;&\#1090;&\#1100; &\#1089;&\#1090;&\#1088;&\#1086;&\#1082;&\#1091;
helpAddDrivers=&\#1044;&\#1072;&\#1073;&\#1072;&\#1074;&\#1083;&\#1103;&\#1077;&\#1084; &\#1076;&\#1088;&\#1072;&\#1081;&\#1074;&\#1077;&\#1088; &\#1073;&\#1072;&\#1079;&\#1099; &\#1076;&\#1072;&\#1085;&\#1085;&\#1099;&\#1093;
helpAddDriversOnlyJava=&\#1058;&\#1086;&\#1083;&\#1100;&\#1082;&\#1086; &\#1074;&\#1077;&\#1088;&\#1089;&\#1080;&\#1103; Java &\#1087;&\#1086;&\#1076;&\#1076;&\#1077;&\#1088;&\#1078;&\#1080;&\#1074;&\#1072;&\#1077;&\#1090; &\#1076;&\#1086;&\#1087;&\#1086;&\#1083;&\#1085;&\#1080;&\#1090;&\#1077;&\#1083;&\#1100;&\#1085;&\#1099;&\#1077; &\#1076;&\#1088;&\#1072;&\#1081;&\#1074;&\#1077;&\#1088;&\#1072; (&\#1101;&\#1090;&\#1072; &\#1086;&\#1087;&\#1094;&\#1080;&\#1103; &\#1085;&\#1077; &\#1087;&\#1086;&\#1076;&\#1076;&\#1077;&\#1088;&\#1078;&\#1080;&\#1074;&\#1072;&\#1077;&\#1090;&\#1089;&\#1103; &\#1088;&\#1086;&\#1076;&\#1085;&\#1086;&\#1081; (&\#1090;&\#1077;&\#1082;&\#1091;&\#1097;&\#1077;&\#1081;) &\#1074;&\#1077;&\#1088;&\#1089;&\#1080;&\#1077;&\#1081;).
helpAddDriversText=&\#1044;&\#1086;&\#1087;&\#1086;&\#1083;&\#1085;&\#1080;&\#1090;&\#1077;&\#1083;&\#1100;&\#1085;&\#1099;&\#1077; &\#1076;&\#1088;&\#1072;&\#1081;&\#1074;&\#1077;&\#1088;&\#1099; &\#1073;&\#1072;&\#1079;&\#1099; &\#1076;&\#1072;&\#1085;&\#1085;&\#1099;&\#1093; &\#1084;&\#1086;&\#1075;&\#1091;&\#1090; &\#1073;&\#1099;&\#1090;&\#1100; &\#1079;&\#1072;&\#1088;&\#1077;&\#1075;&\#1077;&\#1089;&\#1090;&\#1088;&\#1080;&\#1088;&\#1086;&\#1074;&\#1072;&\#1085;&\#1099; &\#1076;&\#1086;&\#1073;&\#1072;&\#1074;&\#1083;&\#1077;&\#1085;&\#1080;&\#1077;&\#1084; &\#1089;&\#1086;&\#1086;&\#1090;&\#1074;&\#1077;&\#1090;&\#1089;&\#1090;&\#1074;&\#1091;&\#1102;&\#1097;&\#1080;&\#1093; Jar-&\#1092;&\#1072;&\#1081;&\#1083;&\#1086;&\#1074; &\#1074; &\#1087;&\#1077;&\#1088;&\#1077;&\#1084;&\#1077;&\#1085;&\#1085;&\#1091;&\#1102; &\#1089;&\#1088;&\#1077;&\#1076;&\#1099; H2DRIVERS &\#1080;&\#1083;&\#1080; &\#1074; CLASSPATH. &\#1055;&\#1088;&\#1080;&\#1084;&\#1077;&\#1088; (Windows)\: &\#1063;&\#1090;&\#1086;&\#1073;&\#1099; &\#1076;&\#1086;&\#1073;&\#1072;&\#1080;&\#1090;&\#1100; &\#1073;&\#1080;&\#1073;&\#1083;&\#1080;&\#1086;&\#1090;&\#1077;&\#1082;&\#1091; &\#1076;&\#1088;&\#1072;&\#1081;&\#1074;&\#1077;&\#1088;&\#1072; &\#1073;&\#1072;&\#1079;&\#1099; &\#1076;&\#1072;&\#1085;&\#1085;&\#1099;&\#1093; C\:\\Programs\\hsqldb\\lib\\hsqldb.jar, &\#1091;&\#1089;&\#1090;&\#1072;&\#1085;&\#1086;&\#1074;&\#1080;&\#1090;&\#1077; &\#1074; &\#1087;&\#1077;&\#1088;&\#1077;&\#1084;&\#1077;&\#1085;&\#1085;&\#1091;&\#1102; &\#1089;&\#1088;&\#1077;&\#1076;&\#1099; H2DRIVERS &\#1079;&\#1085;&\#1072;&\#1095;&\#1077;&\#1085;&\#1080;&\#1077; C\:\\Programs\\hsqldb\\lib\\hsqldb.jar.
helpAddRow=&\#1044;&\#1086;&\#1073;&\#1072;&\#1074;&\#1080;&\#1090;&\#1100; &\#1085;&\#1086;&\#1074;&\#1091;&\#1102; &\#1089;&\#1090;&\#1088;&\#1086;&\#1082;&\#1091;
helpCommandHistory=&\#1055;&\#1086;&\#1082;&\#1072;&\#1079;&\#1099;&\#1074;&\#1072;&\#1077;&\#1090; &\#1080;&\#1089;&\#1090;&\#1086;&\#1088;&\#1080;&\#1102; &\#1074;&\#1099;&\#1087;&\#1086;&\#1083;&\#1077;&\#1085;&\#1085;&\#1099;&\#1093; &\#1082;&\#1086;&\#1084;&\#1072;&\#1085;&\#1076;
......
......@@ -31,7 +31,6 @@ adminTitle=H2 Konsol ayarlar&\#305;
helpAction=Aksiyon
helpAddAnotherRow=Yeni bir sat&\#305;r ekle
helpAddDrivers=Veritaban&\#305; s&\#252;r&\#252;c&\#252;s&\#252; ekle
helpAddDriversOnlyJava=Ek s&\#252;r&\#252;c&\#252;ler sadece Java s&\#252;r&\#252;m&\#252; ile kullan&\#305;labilir.
helpAddDriversText=Yeni veri taban&\#305; s&\#252;r&\#252;c&\#252;leri eklemek i&\#231;in, s&\#252;r&\#252;c&\#252; dosyalar&\#305;n&\#305;n yerini H2DRIVERS yada CLASSPATH &\#231;evre de&\#287;i&\#351;kenlerine ekleyebilirsiniz. &\#214;rnek (Windows)\: S&\#252;r&\#252;c&\#252; dosyas&\#305; C\:\\Programs\\hsqldb\\lib\\hsqldb.jar ise H2DRIVERS de&\#287;i&\#351;kenini C\:\\Programs\\hsqldb\\lib\\hsqldb.jar olarak girin.
helpAddRow=Veri taban&\#305;na yeni bir sat&\#305;r ekler
helpCommandHistory=Komut tarih&\#231;esini g&\#246;sterir
......
......@@ -31,7 +31,6 @@ adminTitle=&\#x041D;&\#x0430;&\#x0441;&\#x0442;&\#x0440;&\#x043E;&\#x0439;&\#x04
helpAction=&\#x0414;&\#x0456;&\#x044F;
helpAddAnotherRow=&\#x0414;&\#x043E;&\#x0434;&\#x0430;&\#x0442;&\#x0438; &\#x043D;&\#x043E;&\#x0432;&\#x0438;&\#x0439; &\#x0440;&\#x044F;&\#x0434;&\#x043E;&\#x043A;
helpAddDrivers=&\#x0414;&\#x043E;&\#x0434;&\#x0430;&\#x0442;&\#x0438; &\#x0434;&\#x0440;&\#x0430;&\#x0439;&\#x0432;&\#x0435;&\#x0440; &\#x0431;&\#x0430;&\#x0437;&\#x0438; &\#x0434;&\#x0430;&\#x043D;&\#x0438;&\#x0445;
helpAddDriversOnlyJava=&\#x041B;&\#x0438;&\#x0448;&\#x0435; Java &\#x0432;&\#x0435;&\#x0440;&\#x0441;&\#x0456;&\#x044F; &\#x043F;&\#x0456;&\#x0434;&\#x0442;&\#x0440;&\#x0438;&\#x043C;&\#x0443;&\#x0454; &\#x0434;&\#x043E;&\#x0434;&\#x0430;&\#x0442;&\#x043A;&\#x043E;&\#x0432;&\#x0456; &\#x0434;&\#x0440;&\#x0430;&\#x0439;&\#x0432;&\#x0435;&\#x0440;&\#x0438; (&\#x0446;&\#x044F; &\#x043C;&\#x043E;&\#x0436;&\#x043B;&\#x0438;&\#x0432;&\#x0456;&\#x0441;&\#x0442;&\#x044C; &\#x043D;&\#x0435; &\#x043F;&\#x0456;&\#x0434;&\#x0442;&\#x0440;&\#x0438;&\#x043C;&\#x0443;&\#x0454;&\#x0442;&\#x044C;&\#x0441;&\#x044F; &\#x0440;&\#x0456;&\#x0434;&\#x043D;&\#x043E;&\#x044E; &\#x0432;&\#x0435;&\#x0440;&\#x0441;&\#x0456;&\#x0454;&\#x044E;).
helpAddDriversText=&\#x041D;&\#x043E;&\#x0432;&\#x0456; &\#x0434;&\#x0440;&\#x0430;&\#x0439;&\#x0432;&\#x0435;&\#x0440;&\#x0438; &\#x0431;&\#x0430;&\#x0437; &\#x0434;&\#x0430;&\#x043D;&\#x0438;&\#x0445; &\#x043C;&\#x043E;&\#x0436;&\#x0443;&\#x0442;&\#x044C; &\#x0431;&\#x0443;&\#x0442;&\#x0438; &\#x0437;&\#x0430;&\#x0440;&\#x0435;&\#x0454;&\#x0441;&\#x0442;&\#x0440;&\#x043E;&\#x0432;&\#x0430;&\#x043D;&\#x0456; &\#x0434;&\#x043E;&\#x0434;&\#x0430;&\#x0432;&\#x0430;&\#x043D;&\#x043D;&\#x044F;&\#x043C; &\#x0448;&\#x043B;&\#x044F;&\#x0445;&\#x0443; &\#x0434;&\#x043E; Jar-&\#x0444;&\#x0430;&\#x0439;&\#x043B;&\#x0443; &\#x0437; &\#x0434;&\#x0440;&\#x0430;&\#x0439;&\#x0432;&\#x0435;&\#x0440;&\#x043E;&\#x043C; &\#x0434;&\#x043E; &\#x0437;&\#x043C;&\#x0456;&\#x043D;&\#x043D;&\#x043E;&\#x0457; &\#x043E;&\#x0442;&\#x043E;&\#x0447;&\#x0435;&\#x043D;&\#x043D;&\#x044F; H2DRIVERS &\#x0430;&\#x0431;&\#x043E; CLASSPATH. &\#x041D;&\#x0430;&\#x043F;&\#x0440;&\#x0438;&\#x043A;&\#x043B;&\#x0430;&\#x0434; (Windows)\: &\#x0429;&\#x043E;&\#x0431; &\#x0434;&\#x043E;&\#x0434;&\#x0430;&\#x0442;&\#x0438; &\#x0434;&\#x0440;&\#x0430;&\#x0439;&\#x0432;&\#x0435;&\#x0440; &\#x0431;&\#x0430;&\#x0437;&\#x0438; &\#x0434;&\#x0430;&\#x043D;&\#x0438;&\#x0445; C\:\\Programs\\hsqldb\\lib\\hsqldb.jar, &\#x0432;&\#x0441;&\#x0442;&\#x0430;&\#x043D;&\#x043E;&\#x0432;&\#x0456;&\#x0442;&\#x044C; &\#x0437;&\#x043C;&\#x0456;&\#x043D;&\#x043D;&\#x0443; &\#x043E;&\#x0442;&\#x043E;&\#x0447;&\#x0435;&\#x043D;&\#x043D;&\#x044F; H2DRIVERS &\#x0440;&\#x0456;&\#x0432;&\#x043D;&\#x043E;&\#x044E; C\:\\Programs\\hsqldb\\lib\\hsqldb.jar.
helpAddRow=&\#x0414;&\#x043E;&\#x0434;&\#x0430;&\#x0442;&\#x0438; &\#x043D;&\#x043E;&\#x0432;&\#x0438;&\#x0439; &\#x0440;&\#x044F;&\#x0434;&\#x043E;&\#x043A;
helpCommandHistory=&\#x041F;&\#x043E;&\#x043A;&\#x0430;&\#x0437;&\#x0443;&\#x0454; &\#x0456;&\#x0441;&\#x0442;&\#x043E;&\#x0440;&\#x0456;&\#x044E; &\#x043A;&\#x043E;&\#x043C;&\#x0430;&\#x043D;&\#x0434;
......
......@@ -31,7 +31,6 @@ adminTitle=H2 \u63A7\u5236\u53F0\u914D\u7F6E
helpAction=\u6D3B\u52A8
helpAddAnotherRow=\u589E\u52A0\u53E6\u4E00\u884C
helpAddDrivers=\u589E\u52A0\u6570\u636E\u5E93\u9A71\u52A8
helpAddDriversOnlyJava=\u53EA\u6709Java\u7248\u672C\u652F\u6301\u589E\u52A0\u9A71\u52A8\uFF08\u672C\u5730\u7248\u672C\u4E0D\u652F\u6301\u8FD9\u4E2A\u7279\u6027\uFF09\u3002
helpAddDriversText=\u53EF\u4EE5\u901A\u8FC7\u6DFB\u52A0\u7CFB\u7EDF\u73AF\u5883\u53D8\u91CFH2DRIVERS \u6216\u8005 CLASSPATH \u6765\u589E\u52A0\u6570\u636E\u5E93\u9A71\u52A8\u6CE8\u518C\u3002\u4F8B\u5982\uFF08Windows\uFF09\uFF1A\u8981\u589E\u52A0\u6570\u636E\u5E93\u9A71\u52A8C\:\\Programs\\hsqldb\\lib\\hsqldb.jar\uFF0C\u53EF\u4EE5\u589E\u52A0\u7CFB\u7EDF\u73AF\u5883\u53D8\u91CFH2DRIVERS\u5E76\u8BBE\u7F6E\u5230C\:\\Programs\\hsqldb\\lib\\hsqldb.jar\u3002
helpAddRow=\u589E\u52A0\u65B0\u7684\u4E00\u884C
helpCommandHistory=\u663E\u793A\u5386\u53F2SQL\u547D\u4EE4
......
......@@ -74,8 +74,6 @@ function set(s) {
<h3>${text.helpAddDrivers}</h3>
<p>
${text.helpAddDriversText}
</p><p>
${text.helpAddDriversOnlyJava}
</p>
</div>
......
......@@ -67,6 +67,7 @@ public abstract class Table extends SchemaObjectBase {
private ObjectArray views;
private boolean checkForeignKeyConstraints = true;
private boolean onCommitDrop, onCommitTruncate;
private Row nullRow;
/**
* Lock the table for the given session.
......@@ -385,13 +386,15 @@ public abstract class Table extends SchemaObjectBase {
}
public Row getNullRow() {
// TODO memory usage: if rows are immutable, we could use a static null
// row
Row row = new Row(new Value[columns.length], 0);
for (int i = 0; i < columns.length; i++) {
row.setValue(i, ValueNull.INSTANCE);
synchronized (this) {
if (nullRow == null) {
nullRow = new Row(new Value[columns.length], 0);
for (int i = 0; i < columns.length; i++) {
nullRow.setValue(i, ValueNull.INSTANCE);
}
}
return nullRow;
}
return row;
}
public Column[] getColumns() {
......
......@@ -242,7 +242,7 @@ public class TableFilter implements ColumnResolver {
state = AFTER_LAST;
} else {
if ((++scanCount & 4095) == 0) {
logScanCount();
checkTimeout();
}
if (cursor.next()) {
currentSearchRow = cursor.getSearchRow();
......@@ -267,21 +267,19 @@ public class TableFilter implements ColumnResolver {
continue;
}
boolean joinConditionOk = isOk(joinCondition);
if (state == FOUND && joinConditionOk) {
foundOne = true;
if (state == FOUND) {
if (joinConditionOk) {
foundOne = true;
} else {
continue;
}
}
if (join != null) {
join.reset();
}
boolean doContinue = false;
if (join != null) {
if (!join.next()) {
doContinue = true;
continue;
}
}
if (doContinue) {
continue;
}
// check if it's ok
if (state == NULL_ROW || joinConditionOk) {
return true;
......@@ -291,7 +289,8 @@ public class TableFilter implements ColumnResolver {
return false;
}
private void logScanCount() {
private void checkTimeout() throws SQLException {
session.checkCancelled();
// System.out.println(this.alias+ " " + table.getName() + ": " + scanCount);
}
......
......@@ -34,6 +34,8 @@ import org.h2.util.StringUtils;
/**
* A facility to read from and write to CSV (comma separated values) files.
*
* @author Thomas Mueller, Sylvain Cuaz
*/
public class Csv implements SimpleRowSource {
......@@ -47,6 +49,7 @@ public class Csv implements SimpleRowSource {
private char fieldDelimiter = '\"';
private char escapeCharacter = '\"';
private String lineSeparator = SysProperties.LINE_SEPARATOR;
private String nullString = "";
private String fileName;
private Reader reader;
private Writer writer;
......@@ -256,6 +259,8 @@ public class Csv implements SimpleRowSource {
} else {
writer.write(s);
}
} else if (nullString.length() > 0) {
writer.write(nullString);
}
}
if (rowSeparatorWrite != null) {
......@@ -351,8 +356,10 @@ public class Csv implements SimpleRowSource {
// ignore spaces
continue;
} else if (ch == fieldSeparatorRead) {
// null
break;
} else if (ch == fieldDelimiter) {
// delimited value
StringBuffer buff = new StringBuffer();
boolean containsEscape = false;
while (true) {
......@@ -403,6 +410,7 @@ public class Csv implements SimpleRowSource {
}
break;
} else if (ch == commentLineStart) {
// comment until end of line
while (true) {
ch = readChar();
if (ch < 0 || ch == '\r' || ch == '\n') {
......@@ -412,6 +420,7 @@ public class Csv implements SimpleRowSource {
endOfLine = true;
break;
} else {
// undelimited value
StringBuffer buff = new StringBuffer();
buff.append((char) ch);
while (true) {
......@@ -427,7 +436,8 @@ public class Csv implements SimpleRowSource {
}
buff.append((char) ch);
}
value = buff.toString().trim();
// check undelimited value for nullString
value = readNull(buff.toString().trim());
break;
}
}
......@@ -435,6 +445,10 @@ public class Csv implements SimpleRowSource {
return StringCache.get(value);
}
private String readNull(String s) {
return s.equals(nullString) ? null : s;
}
private String unEscape(String s) {
StringBuffer buff = new StringBuffer(s.length());
int start = 0;
......@@ -622,4 +636,13 @@ public class Csv implements SimpleRowSource {
this.lineSeparator = lineSeparator;
}
/**
* Set the value that represents NULL.
*
* @param nullString the null
*/
public void setNullString(String nullString) {
this.nullString = nullString;
}
}
......@@ -51,6 +51,8 @@ public class RandomUtils {
}
};
Thread t = new Thread(runnable);
// let the process terminate even if generating the seed is really slow
t.setDaemon(true);
t.start();
Thread.yield();
try {
......
......@@ -14,25 +14,29 @@ import org.h2.constant.SysProperties;
public class StartBrowser {
public static void openURL(String url) {
String osName = SysProperties.getStringSetting("os.name", "Linux");
String osName = SysProperties.getStringSetting("os.name", "linux").toLowerCase();
Runtime rt = Runtime.getRuntime();
try {
if (osName.startsWith("Windows")) {
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
} else if (osName.startsWith("Mac OS X")) {
// Runtime.getRuntime().exec("open -a safari " + url);
// Runtime.getRuntime().exec("open " + url + "/index.html");
Runtime.getRuntime().exec("open " + url);
if (osName.indexOf("windows") >= 0) {
rt.exec(new String[] { "rundll32", "url.dll,FileProtocolHandler", url });
} else if (osName.indexOf("mac") >= 0) {
Runtime.getRuntime().exec(new String[] { "open", url });
} else {
try {
Runtime.getRuntime().exec("firefox " + url);
} catch (Exception e) {
String[] browsers = { "firefox", "mozilla-firefox", "mozilla", "konqueror", "netscape", "opera" };
boolean ok = false;
for (int i = 0; i < browsers.length; i++) {
try {
Runtime.getRuntime().exec("mozilla-firefox " + url);
} catch (Exception e2) {
// No success in detection.
System.out.println("Please open a browser and go to " + url);
rt.exec(new String[] { browsers[i], url });
ok = true;
break;
} catch (Exception e) {
// ignore and try the next
}
}
if (!ok) {
// No success in detection.
System.out.println("Please open a browser and go to " + url);
}
}
} catch (IOException e) {
System.out.println("Failed to start a browser to open the URL " + url);
......
......@@ -66,6 +66,7 @@ import org.h2.test.jdbcx.TestXA;
import org.h2.test.jdbcx.TestXASimple;
import org.h2.test.mvcc.TestMvcc1;
import org.h2.test.mvcc.TestMvcc2;
import org.h2.test.mvcc.TestMvcc3;
import org.h2.test.server.TestNestedLoop;
import org.h2.test.server.TestPgServer;
import org.h2.test.server.TestWeb;
......@@ -155,55 +156,10 @@ java org.h2.test.TestAll timer
/*
apple:
- console doesn't always work in safari, fix
C:\temp\db
select.sql
ant 'get' for dependencies
H2 is an SQL database engine written in Java.
It is very fast and small (about 1 MB).
Embedded, server, and clustering modes are available.
A browser based console application is included.
Disk based and in-memory tables and databases are supported.
Some of its features are transactions isolation, multi-version concurrency
(MVCC), level locking, encrypted databases, fulltext search,
and strong security.
The main API is JDBC, however ODBC and others are also
supported via PostgreSQL network protocol compatibility.
I was looking at MVCC today, I hope it will solve some of my problems
in future. MVCC is listed in the "Advanced Topics" documentation
without any warnings. However, I have encountered a major problem. All
you need to do is use jdbc:h2:test;MVCC=true with a range comparison
in a WHERE clause on an indexed column:
SET AUTOCOMMIT TRUE;
DROP TABLE IF EXISTS test;
CREATE TABLE test (id IDENTITY, A INT, B INT);
CREATE INDEX A ON test(A);
INSERT INTO test VALUES(0, 0, 0);
INSERT INTO test VALUES(2, 2, 2);
SET AUTOCOMMIT FALSE;
SELECT * FROM test WHERE id BETWEEN 0 AND 2;
-- Returned the correct result: TABLE(ID INT=(0,2), A INT=(0,2), B INT=(0,2))
INSERT INTO test VALUES(1, 1, 1);
SELECT * FROM test;
-- Returned the correct result: TABLE(ID INT=(0,2,1), A INT=(0,2,1), B INT=(0,2,1))
SELECT * FROM test WHERE id IS NOT NULL;
-- Returned the correct result: TABLE(ID INT=(0,2,1), A INT=(0,2,1), B INT=(0,2,1))
SELECT * FROM test WHERE id <> 99;
-- Returned the correct result: TABLE(ID INT=(0,2,1), A INT=(0,2,1), B INT=(0,2,1))
SELECT * FROM test WHERE id < 99;
-- Returned WRONG result: TABLE(ID INT=(1,1,2), A INT=(1,1,2), B INT=(1,1,2))
SELECT * FROM test WHERE id >= 0;
-- Returned WRONG result: TABLE(ID INT=(1,1,2), A INT=(1,1,2), B INT=(1,1,2))
SELECT * FROM test WHERE A >= 0;
-- Returned WRONG result: TABLE(ID INT=(1,1,2), A INT=(1,1,2), B INT=(1,1,2))
SELECT * FROM test WHERE B >= 0;
-- Returned the correct result: TABLE(ID INT=(0,2,1), A INT=(0,2,1), B INT=(0,2,1))
If you have a 2nd connection open while the 1st connection's
transaction is uncommitted, the 2nd connection also returns the wrong
result set! This is the same whether the lock mode is READ_COMMITTED
or SERIALIZABLE.
test startbrowser with ubuntu
fix or disable the linear hash index
......@@ -212,9 +168,25 @@ link to new changelog and roadmap, remove pages from google groups
Can sometimes not delete log file? need test case
ant 'get' for dependencies
Add where required // TODO: change in version 1.1
History:
When using multi-version concurrency (MVCC=TRUE), duplicate rows could appear in the result set when running queries
with uncommitted changes in the same session.
H2 Console: remote connections were very slow because getHostName/getRemoteHost was used. Fixed (now using getHostAddress/getRemoteAddr.
H2 Console: on Linux, Firefox is now started if available. This has been tested on Ubuntu.
H2 Console: the start window works better with IKVM
H2 Console: improved compatibility with Safari (Safari requires keep-alive)
Random: the process didn't stop if generating the random seed using the standard
way (SecureRandom.generateSeed) was very slow. Now using a daemon thread
to avoid this problem.
SELECT UNION with a different number of ORDER BY columns did throw an ArrayIndexOutOfBoundsException.
When using view, the precision of column was changed to the default scale for some data types.
CSVWRITE now supports a 'null string' that is used for parsing and writing NULL.
Some long running queries could not be cancelled.
Queries with many outer join tables were very slow. Fixed.
Roadmap:
......@@ -490,6 +462,7 @@ Roadmap:
// mvcc
new TestMvcc1().runTest(this);
new TestMvcc2().runTest(this);
new TestMvcc3().runTest(this);
// synth
new TestCrashAPI().runTest(this);
......
......@@ -17,6 +17,7 @@ import java.util.Random;
import org.h2.test.TestBase;
import org.h2.tools.Csv;
import org.h2.util.FileUtils;
import org.h2.util.IOUtils;
import org.h2.util.StringUtils;
......@@ -26,6 +27,7 @@ import org.h2.util.StringUtils;
public class TestCsv extends TestBase {
public void test() throws Exception {
testNull();
testRandomData();
testEmptyFieldDelimiter();
testFieldDelimiter();
......@@ -35,6 +37,52 @@ public class TestCsv extends TestBase {
testPipe();
}
/**
* Test custom NULL string.
*
* @author Sylvain Cuaz, Thomas Mueller
*/
public void testNull() throws Exception {
deleteDb("csv");
File f = new File(baseDir + "/testNull.csv");
FileUtils.delete(f.getAbsolutePath());
RandomAccessFile file = new RandomAccessFile(f, "rw");
String csvContent = "\"A\",\"B\",\"C\",\"D\"\n\\N,\"\",\"\\N\",";
file.write(csvContent.getBytes("UTF-8"));
file.close();
Csv csv = Csv.getInstance();
csv.setNullString("\\N");
ResultSet rs = csv.read(f.getPath(), null, "UTF8");
ResultSetMetaData meta = rs.getMetaData();
check(meta.getColumnCount(), 4);
check(meta.getColumnLabel(1), "A");
check(meta.getColumnLabel(2), "B");
check(meta.getColumnLabel(3), "C");
check(meta.getColumnLabel(4), "D");
check(rs.next());
check(rs.getString(1), null);
check(rs.getString(2), "");
// null is never quoted
check(rs.getString(3), "\\N");
// an empty string is always parsed as null
check(rs.getString(4), null);
checkFalse(rs.next());
Connection conn = getConnection("csv");
Statement stat = conn.createStatement();
stat.execute("call csvwrite('" + f.getPath() + "', 'select NULL as a, '''' as b, ''\\N'' as c, NULL as d', 'UTF8', ',', '\"', NULL, '\\N', '\n')");
FileReader reader = new FileReader(f);
// on read, an empty string is treated like null,
// but on write a null is always written with the nullString
String data = IOUtils.readStringAndClose(reader, -1);
check(csvContent + "\\N", data.trim());
conn.close();
FileUtils.delete(f.getAbsolutePath());
}
private void testRandomData() throws Exception {
deleteDb("csv");
Connection conn = getConnection("csv");
......@@ -82,7 +130,7 @@ public class TestCsv extends TestBase {
f.delete();
Connection conn = getConnection("csv");
Statement stat = conn.createStatement();
stat.execute("call csvwrite('"+baseDir+"/test.csv', 'select 1 id, ''Hello'' name', null, '|', '', null, chr(10))");
stat.execute("call csvwrite('"+baseDir+"/test.csv', 'select 1 id, ''Hello'' name', null, '|', '', null, null, chr(10))");
FileReader reader = new FileReader(baseDir + "/test.csv");
String text = IOUtils.readStringAndClose(reader, -1).trim();
text = StringUtils.replaceAll(text, "\n", " ");
......
......@@ -8,6 +8,7 @@ import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.Driver;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;
import java.sql.Types;
......@@ -29,6 +30,7 @@ public class TestMetaData extends TestBase {
deleteDb("metaData");
conn = getConnection("metaData");
testColumnPrecision();
testColumnDefault();
testCrossReferences();
testProcedureColumns();
......@@ -191,6 +193,27 @@ public class TestMetaData extends TestBase {
}
private void testColumnPrecision() throws Exception {
Statement stat = conn.createStatement();
stat.execute("CREATE TABLE ONE(X NUMBER(12,2), Y FLOAT)");
stat.execute("CREATE TABLE TWO AS SELECT * FROM ONE");
ResultSet rs;
ResultSetMetaData meta;
rs = stat.executeQuery("SELECT * FROM ONE");
meta = rs.getMetaData();
check(12, meta.getPrecision(1));
check(17, meta.getPrecision(2));
check(Types.DECIMAL, meta.getColumnType(1));
check(Types.DOUBLE, meta.getColumnType(2));
rs = stat.executeQuery("SELECT * FROM TWO");
meta = rs.getMetaData();
check(12, meta.getPrecision(1));
check(17, meta.getPrecision(2));
check(Types.DECIMAL, meta.getColumnType(1));
check(Types.DOUBLE, meta.getColumnType(2));
stat.execute("DROP TABLE ONE, TWO");
}
private void testColumnDefault() throws Exception {
DatabaseMetaData meta = conn.getMetaData();
ResultSet rs;
......
/*
* Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.test.mvcc;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import org.h2.test.TestBase;
/**
* Additional MVCC (multi version concurrency) test cases.
*/
public class TestMvcc3 extends TestBase {
public void test() throws Exception {
if (!config.mvcc) {
return;
}
deleteDb("mvcc3");
Connection conn = getConnection("mvcc3");
Statement stat = conn.createStatement();
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY)");
stat.execute("INSERT INTO TEST VALUES(0)");
conn.setAutoCommit(false);
stat.execute("INSERT INTO TEST VALUES(1)");
ResultSet rs = stat.executeQuery("SELECT * FROM TEST ORDER BY ID");
rs.next();
check(0, rs.getInt(1));
rs.next();
check(1, rs.getInt(1));
conn.close();
}
}
--- special grammar and test cases ---------------------------------------------------------------------------------------------
(SELECT X FROM DUAL ORDER BY X+2) UNION SELECT X FROM DUAL;
> X
> -
> 1
> 1
> rows (ordered): 2
create table test(a int, b int default 1);
> ok
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论