faq.html 9.9 KB
Newer Older
1 2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Thomas Mueller's avatar
Thomas Mueller committed
3
Copyright 2004-2009 H2 Group. Multiple-Licensed under the H2 License, Version 1.0,
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
and under the Eclipse Public License, Version 1.0
(http://h2database.com/html/license.html).
Initial Developer: H2 Group
-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><title>
Frequently Asked Questions
</title><link rel="stylesheet" type="text/css" href="stylesheet.css" />
<!-- [search] { -->
<script type="text/javascript" src="navigation.js"></script>
</head><body onload="frameMe();">
<table class="content"><tr class="content"><td class="content"><div class="contentDiv">
<!-- } -->

<h1>Frequently Asked Questions</h1>

<a href="#known_bugs">
    Are there Known Bugs? When is the Next Release?</a><br />
<a href="#open_source">
    Is this Database Engine Open Source?</a><br />
<a href="#query_slow">
    My Query is Slow</a><br />
<a href="#create_database">
    How to Create a New Database?</a><br />
<a href="#connect">
    How to Connect to a Database?</a><br />
<a href="#database_files">
    Where are the Database Files Stored?</a><br />
<a href="#size_limit">
    What is the Size Limit (Maximum Size) of a Database?</a><br />
<a href="#reliable">
    Is it Reliable?</a><br />
<a href="#slow_open">
    Why is Opening my Database Slow?</a><br />
<a href="#gcj">
    Is the GCJ Version Stable? Faster?</a><br />
<a href="#translate">
    How to Translate this Project?</a><br />

Thomas Mueller's avatar
Thomas Mueller committed
43 44
<br />
<h3 id="known_bugs">Are there Known Bugs? When is the Next Release?</h3>
45 46 47 48
<p>
Usually, bugs get fixes as they are found. There is a release every few weeks.
Here is the list of known and confirmed issues:
</p>
49
<ul><li>Tomcat and Glassfish 3 set most static fields (final or non-final) to null when
50
    unloading a web application. This can cause a <code class="notranslate">NullPointerException</code> in H2 versions
51 52
    1.1.107 and older, and may still not work in newer versions. Please report it if you
    run into this issue. In Tomcat >= 6.0 this behavior can be disabled by setting the
53
    system property <code class="notranslate">org.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES</code>
54
    to false, however Tomcat may then run out of memory. A known workaround is to
55 56
    put the h2.jar file in a shared <code class="notranslate">lib</code> directory
    (<code class="notranslate">common/lib</code>).
57 58
</li><li>Some problems have been found with right outer join. Internally, it is converted
    to left outer join, which does not always produce the same results as other databases
59
    when used in combination with other joins.
60
</li><li>When using Install4j before 4.1.4 on Linux and enabling 'pack200',
61 62 63
    the <code class="notranslate">h2*.jar</code> becomes corrupted by the install process, causing application failure.
    A workaround is to add an empty file <code class="notranslate">h2*.jar.nopack</code>
    next to the <code class="notranslate">h2*.jar</code> file.
64 65 66
    This problem is solved in Install4j 4.1.4.
</li></ul>

Thomas Mueller's avatar
Thomas Mueller committed
67 68
<br />
<h3 id="open_source">Is this Database Engine Open Source?</h3>
69 70 71 72 73
<p>
Yes. It is free to use and distribute, and the source code is included.
See also under license.
</p>

Thomas Mueller's avatar
Thomas Mueller committed
74 75
<br />
<h3 id="query_slow">My Query is Slow</h3>
76
<p>
77 78
Slow <code class="notranslate">SELECT</code> (or <code class="notranslate">DELETE, UPDATE, MERGE</code>)
statement can have multiple reasons. Follow this checklist:
79 80
</p>
<ul>
81 82 83 84 85
<li>Run <code class="notranslate">ANALYZE</code> (see documentation for details).
</li><li>Run the query with <code class="notranslate">EXPLAIN</code> and check if indexes are used
    (see documentation for details).
</li><li>If required, create additional indexes and try again using
    <code class="notranslate">ANALYZE</code> and <code class="notranslate">EXPLAIN</code>.
86 87 88 89
</li><li>If it doesn't help please report the problem.
</li>
</ul>

Thomas Mueller's avatar
Thomas Mueller committed
90 91
<br />
<h3 id="create_database">How to Create a New Database?</h3>
92 93 94 95
<p>
By default, a new database is automatically created if it does not yet exist.
</p>

Thomas Mueller's avatar
Thomas Mueller committed
96 97
<br />
<h3 id="connect">How to Connect to a Database?</h3>
98
<p>
99 100
The database driver is <code class="notranslate">org.h2.Driver</code>,
and the database URL starts with <code class="notranslate">jdbc:h2:</code>.
101 102
To connect to a database using JDBC, use the following code:
</p>
103
<pre class="notranslate">
104 105 106 107
Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection("jdbc:h2:~/test", "sa", "");
</pre>

Thomas Mueller's avatar
Thomas Mueller committed
108 109
<br />
<h3 id="database_files">Where are the Database Files Stored?</h3>
110
<p>
111 112 113 114 115 116 117
When using database URLs like <code class="notranslate">jdbc:h2:~/test</code>,
the database is stored in the user directory.
For Windows, this is usually C:\Documents and Settings\&lt;userName&gt;.
If the base directory is not set (as in <code class="notranslate">jdbc:h2:test</code>),
the database files are stored in the directory where the application is started
(the current working directory). When using the H2 Console application from the start menu,
this is "&lt;Installation Directory&gt;/bin".
118
The base directory can be set in the database URL. A fixed or relative path can be used. When using the URL
119 120 121 122
<code class="notranslate">jdbc:h2:file:data/sample</code>, the database is stored in the directory
<code class="notranslate">data</code> (relative to the current working directory).
The directory is created automatically if it does not yet exist. It is also possible to use the
fully qualified directory name (and for Windows, drive name).
123
Example: <code class="notranslate">jdbc:h2:file:C:/data/test</code>
124 125
</p>

Thomas Mueller's avatar
Thomas Mueller committed
126 127
<br />
<h3 id="size_limit">What is the Size Limit (Maximum Size) of a Database?</h3>
128
<p>
Thomas Mueller's avatar
Thomas Mueller committed
129
See <a href="advanced.html#limits_limitations">Limits and Limitations</a>.
130 131
</p>

Thomas Mueller's avatar
Thomas Mueller committed
132 133
<br />
<h3 id="reliable">Is it Reliable?</h3>
134
<p>
135
Some users have reported that after a power failure, the database can sometimes not be
136
opened because the index file is corrupt. In that case, the index file can be deleted
137 138 139 140
(it is automatically re-created). To avoid this, append
<code class="notranslate">;LOG=2</code> to the database URL.
See also: <a href="grammar.html#set_log" class="notranslate">SET LOG</a>. This problem will be solved
using the new 'page store' mechanism (currently beta).
141 142
</p>
<p>
143 144
That is not easy to say. It is still a quite new product. A lot of tests have been written,
and the code coverage of these tests is very high. Randomized stress tests
145
are run regularly. But there are probably still
146
bugs that have not yet been found (as with most software). Some features are known
147 148
to be dangerous, they are only supported for situations where performance is more important
than reliability. Those dangerous features are:
149 150
</p>
<ul>
151 152 153
<li>Disabling the transaction log mechanism using <code class="notranslate">SET LOG 0</code>.
</li><li>Using the transaction isolation level <code class="notranslate">READ_UNCOMMITTED</code>
    (<code class="notranslate">LOCK_MODE 0</code>) while at the same time using multiple
154
    connections.
155 156 157
</li><li>Disabling database file protection using <code class="notranslate">FILE_LOCK=NO</code>
    in the database URL.
</li><li>Disabling referential integrity using <code class="notranslate">SET REFERENTIAL_INTEGRITY FALSE</code>.
158 159 160
</li></ul>
<p>
In addition to that, running out of memory should be avoided.
161
In older versions, OutOfMemory errors while using the database could corrupt a databases.
162 163 164 165 166
</p>
<p>
Areas that are not fully tested:
</p>
<ul>
Thomas Mueller's avatar
Thomas Mueller committed
167
<li>Platforms other than Windows XP, Linux, Mac OS X, or JVMs other than Sun 1.5 or 1.6
168 169
</li><li>The features <code class="notranslate">AUTO_SERVER</code> and
    <code class="notranslate">AUTO_RECONNECT</code>
170 171 172 173 174
</li><li>The MVCC (multi version concurrency) mode
</li><li>Cluster mode, 2-phase commit, savepoints
</li><li>24/7 operation
</li><li>Some operations on databases larger than 500 MB may be slower than expected
</li><li>The optimizer may not always select the best plan
175 176
</li><li>Fulltext search
</li><li>Operations on LOBs over 2 GB
177 178 179
</li></ul>

<p>
180
Areas considered experimental are:
181 182 183
</p>
<ul>
<li>The PostgreSQL server
184
</li><li>Multi-threading within the engine using <code class="notranslate">SET MULTI_THREADED=1</code>
185 186 187
</li><li>Compatibility modes for other databases (only some features are implemented)
</li></ul>

Thomas Mueller's avatar
Thomas Mueller committed
188 189
<br />
<h3 id="slow_open">Why is Opening my Database Slow?</h3>
190 191 192 193
<p>
If it takes a long time to open a database, in most cases it was not closed the last time.
This is specially a problem for larger databases.
To close a database, close all connections to it before the application ends, or execute
194 195
the command <code class="notranslate">SHUTDOWN</code>.
The database is also closed when the virtual machine exits normally
196
by using a shutdown hook. However killing a Java process or calling Runtime.halt will prevent this.
197
The reason why opening is slow in this situations is that indexes are re-created.
198 199
If you  can not guarantee the database is closed, consider using
<code class="notranslate">SET LOG 2</code> (see SQL Grammar).
200 201 202 203 204 205 206 207 208 209 210
</p>
<p>
To find out what the problem is, open the database in embedded mode using the H2 Console.
This will print progress information. If you have many 'Creating index' lines it is an indication that the
database was not closed the last time.
</p>
<p>
Other possible reasons are: the database is very big (many GB), or contains linked tables
that are slow to open.
</p>

Thomas Mueller's avatar
Thomas Mueller committed
211 212
<br />
<h3 id="gcj">Is the GCJ Version Stable? Faster?</h3>
213 214 215 216 217 218 219 220
<p>
The GCJ version is not as stable as the Java version.
When running the regression test with the GCJ version, sometimes the application just stops
at what seems to be a random point without error message.
Currently, the GCJ version is also slower than when using the Sun VM.
However, the startup of the GCJ version is faster than when using a VM.
</p>

Thomas Mueller's avatar
Thomas Mueller committed
221 222
<br />
<h3 id="translate">How to Translate this Project?</h3>
223 224 225 226 227 228
<p>
For more information, see
<a href="build.html#translating">Build/Translating</a>.
</p>

<!-- [close] { --></div></td></tr></table><!-- } --><!-- analytics --></body></html>