faq.html 11.3 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">
<!--
3
Copyright 2004-2010 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
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>

20 21
<a href="#support">
    I Have a Problem or Feature Request</a><br />
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
<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 />
40 41
<a href="#column_names_incorrect">
    Column Names are Incorrect?</a><br />
Thomas Mueller's avatar
Thomas Mueller committed
42 43
<a href="#float_is_double">
    Float is Double?</a><br />
44 45 46 47
<a href="#gcj">
    Is the GCJ Version Stable? Faster?</a><br />
<a href="#translate">
    How to Translate this Project?</a><br />
48

49 50 51 52
<h3 id="support">I Have a Problem or Feature Request</h3>
<p>
Please read the <a href="build.html#support">support checklist</a>.
</p>
53

Thomas Mueller's avatar
Thomas Mueller committed
54
<h3 id="known_bugs">Are there Known Bugs? When is the Next Release?</h3>
55 56 57 58
<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>
59 60
<ul><li>Tomcat and Glassfish 3 set most static fields (final or non-final) to <code>null</code> when
    unloading a web application. This can cause a <code>NullPointerException</code> in H2 versions
61
    1.1.107 and older, and may still not work in newer versions. Please report it if you
Thomas Mueller's avatar
Thomas Mueller committed
62
    run into this issue. In Tomcat &gt;= 6.0 this behavior can be disabled by setting the
63 64 65
    system property <code>org.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false</code>,
    however Tomcat may then run out of memory. A known workaround is to
    put the <code>h2*.jar</code> file in a shared <code>lib</code> directory
66
    (<code>common/lib</code>).
67 68
</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
69
    when used in combination with other joins.
70 71 72 73
</li><li>When using Install4j before 4.1.4 on Linux and enabling <code>pack200</code>,
    the <code>h2*.jar</code> becomes corrupted by the install process, causing application failure.
    A workaround is to add an empty file <code>h2*.jar.nopack</code>
    next to the <code>h2*.jar</code> file.
74 75
    This problem is solved in Install4j 4.1.4.
</li></ul>
Thomas Mueller's avatar
Thomas Mueller committed
76 77 78
<p>
For a complete list, see <a href="http://code.google.com/p/h2database/issues/list">Open Issues</a>.
</p>
79

Thomas Mueller's avatar
Thomas Mueller committed
80
<h3 id="open_source">Is this Database Engine Open Source?</h3>
81 82 83 84 85
<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
86
<h3 id="query_slow">My Query is Slow</h3>
87
<p>
88
Slow <code>SELECT</code> (or <code>DELETE, UPDATE, MERGE</code>)
89
statement can have multiple reasons. Follow this checklist:
90 91
</p>
<ul>
92 93
<li>Run <code>ANALYZE</code> (see documentation for details).
</li><li>Run the query with <code>EXPLAIN</code> and check if indexes are used
94 95
    (see documentation for details).
</li><li>If required, create additional indexes and try again using
96
    <code>ANALYZE</code> and <code>EXPLAIN</code>.
97 98 99 100
</li><li>If it doesn't help please report the problem.
</li>
</ul>

Thomas Mueller's avatar
Thomas Mueller committed
101
<h3 id="create_database">How to Create a New Database?</h3>
102 103
<p>
By default, a new database is automatically created if it does not yet exist.
104
See <a href="tutorial.html#creating_new_databases">Creating New Databases</a>.
105 106
</p>

Thomas Mueller's avatar
Thomas Mueller committed
107
<h3 id="connect">How to Connect to a Database?</h3>
108
<p>
109 110
The database driver is <code>org.h2.Driver</code>,
and the database URL starts with <code>jdbc:h2:</code>.
111 112
To connect to a database using JDBC, use the following code:
</p>
113
<pre>
114 115 116 117
Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection("jdbc:h2:~/test", "sa", "");
</pre>

Thomas Mueller's avatar
Thomas Mueller committed
118
<h3 id="database_files">Where are the Database Files Stored?</h3>
119
<p>
120
When using database URLs like <code>jdbc:h2:~/test</code>,
121
the database is stored in the user directory.
122
For Windows, this is usually <code>C:\Documents and Settings\&lt;userName&gt;</code>.
123
If the base directory is not set (as in <code>jdbc:h2:test</code>),
124 125
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,
126
this is <code>&lt;Installation Directory&gt;/bin</code>.
127
The base directory can be set in the database URL. A fixed or relative path can be used. When using the URL
128 129
<code>jdbc:h2:file:data/sample</code>, the database is stored in the directory
<code>data</code> (relative to the current working directory).
130 131
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).
132
Example: <code>jdbc:h2:file:C:/data/test</code>
133 134
</p>

Thomas Mueller's avatar
Thomas Mueller committed
135
<h3 id="size_limit">What is the Size Limit (Maximum Size) of a Database?</h3>
136
<p>
Thomas Mueller's avatar
Thomas Mueller committed
137
See <a href="advanced.html#limits_limitations">Limits and Limitations</a>.
138 139
</p>

Thomas Mueller's avatar
Thomas Mueller committed
140
<h3 id="reliable">Is it Reliable?</h3>
141 142 143
<p>
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
144
are run regularly. But there are probably still
145
bugs that have not yet been found (as with most software). Some features are known
146 147
to be dangerous, they are only supported for situations where performance is more important
than reliability. Those dangerous features are:
148
</p>
Thomas Mueller's avatar
Thomas Mueller committed
149
<ul><li>Using the transaction isolation level <code>READ_UNCOMMITTED</code>
150
    (<code>LOCK_MODE 0</code>) while at the same time using multiple
151
    connections.
152
</li><li>Disabling database file protection using <code>FILE_LOCK=NO</code>
153
    in the database URL.
154
</li><li>Disabling referential integrity using <code>SET REFERENTIAL_INTEGRITY FALSE</code>.
155 156 157
</li></ul>
<p>
In addition to that, running out of memory should be avoided.
158
In older versions, OutOfMemory errors while using the database could corrupt a databases.
159 160
</p>
<p>
161
Some areas of this database are not fully tested.
Thomas Mueller's avatar
Thomas Mueller committed
162
When using one of those features for production, please ensure your use case
163 164
is well tested (if possible with automated test cases).
Those areas are:
165 166
</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>AUTO_SERVER</code> and
    <code>AUTO_RECONNECT</code>
170
</li><li>The file locking method 'Serialized'
171 172 173 174 175
</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
176 177
</li><li>Fulltext search
</li><li>Operations on LOBs over 2 GB
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>SET MULTI_THREADED=1</code>
185
</li><li>Compatibility modes for other databases (only some features are implemented)
186 187
</li><li>The soft reference cache (CACHE_TYPE=SOFT_LRU). It might not improve performance,
    and out of memory issues have been reported.
188
</li></ul>
189
<p>
Thomas Mueller's avatar
Thomas Mueller committed
190 191 192
Some users have reported that after a power failure, the database cannot be opened sometimes.
In this case, use a backup of the database or the Recover tool. Please report such problems.
The plan is that the database automatically recovers in all situations.
193
</p>
194

195 196 197 198 199 200 201 202 203
<h3 id="column_names_incorrect">Column Names are Incorrect?</h3>
<p>
For the query <code>SELECT ID AS X FROM TEST</code> the method
<code>ResultSetMetaData.getColumnName()</code> returns <code>ID</code>, I expect it to
return <code>X</code>. What's wrong?
</p>
<p>
This is not a bug. According the the JDBC specification, the method
<code>ResultSetMetaData.getColumnName()</code> should return the name of the column
204
and not the alias name. If you need the alias name, use
205
<a href="http://java.sun.com/javase/6/docs/api/java/sql/ResultSetMetaData.html#getColumnLabel(int)"><code>ResultSetMetaData.getColumnLabel()</code></a>.
206
Other database don't work like this (they don't follow the JDBC specification).
207
If you need compatibility with those databases, use the <a href="features.html#compatibility">Compatibility Mode</a>,
208 209
or set the system property <a href="../javadoc/org/h2/constant/SysProperties.html#h2.aliasColumnName"><code>h2.aliasColumnName</code></a>.
</p>
Thomas Mueller's avatar
Thomas Mueller committed
210 211 212 213
<p>
This also applies to DatabaseMetaData calls that return a result set.
The columns in the JDBC API are column labels, not column names.
</p>
214

Thomas Mueller's avatar
Thomas Mueller committed
215 216 217 218 219 220 221
<h3 id="float_is_double">Float is Double?</h3>
<p>
For a table defined as <code>CREATE TABLE TEST(X FLOAT)</code> the method
<code>ResultSet.getObject()</code> returns a <code>java.lang.Double</code>, I expect it to
return a <code>java.lang.Float</code>. What's wrong?
</p>
<p>
222
This is not a bug. According the the JDBC specification, the JDBC data type <code>FLOAT</code>
Thomas Mueller's avatar
Thomas Mueller committed
223
is equivalent to <code>DOUBLE</code>, and both are mapped to <code>java.lang.Double</code>.
224
See also
Thomas Mueller's avatar
Thomas Mueller committed
225 226 227
<a href="http://java.sun.com/j2se/1.5.0/docs/guide/jdbc/getstart/mapping.html#1055162">
Mapping SQL and Java Types - 8.3.10 FLOAT</a>.</p>

Thomas Mueller's avatar
Thomas Mueller committed
228
<h3 id="slow_open">Why is Opening my Database Slow?</h3>
229
<p>
Thomas Mueller's avatar
Thomas Mueller committed
230 231 232 233
To find out what the problem is, use the H2 Console and click on "Test Connection"
instead of "Login". After the "Login Successful" appears, click on it (it's a link).
This will list the top stack traces. Then either analyze this yourself, or
post those stack traces in the Google Group.
234 235 236
</p>
<p>
To find out what the problem is, open the database in embedded mode using the H2 Console.
237
This will print progress information. If you have many lines with 'Creating index' it is an indication that the
238 239 240 241 242 243 244
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
245
<h3 id="gcj">Is the GCJ Version Stable? Faster?</h3>
246 247 248 249 250 251 252 253
<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
254
<h3 id="translate">How to Translate this Project?</h3>
255 256 257 258 259 260
<p>
For more information, see
<a href="build.html#translating">Build/Translating</a>.
</p>

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