提交 1256ab7b authored 作者: Thomas Mueller's avatar Thomas Mueller

Cheat sheet

上级 800c3dfa
......@@ -11,15 +11,13 @@ H2 Database Engine
</title>
<style type="text/css">
td, input, select, textarea, body, td, th {
font: 9pt/130% Tahoma, Arial, Helvetica, sans-serif;
font: 9pt Tahoma, Arial, Helvetica, sans-serif;
font-weight: normal;
}
h1, h2, h3, h4, h5 {
font: 9pt Tahoma, Arial, Helvetica, sans-serif;
font-weight: bold;
}
h1 {
background-color: #0000bb;
padding: 2px 4px 2px 4px;
......@@ -27,39 +25,48 @@ h1 {
font-size: 15pt;
line-height: normal;
}
h2 {
font-size: 10pt;
}
a.link {
text-decoration: underline;
color: blue;
}
a.link:hover {
text-decoration: underline;
color: blue;
}
a {
text-decoration: none;
color: black;
}
a:hover {
text-decoration: underline;
color: blue;
}
td, input, select, textarea, body, code, pre {
font-size: 9pt;
}
pre {
background-color: #ece9d8;
border: 1px solid rgb(172, 168, 153);
padding: 4px;
}
code {
background-color: #ece9d8;
padding: 0px 2px;
}
table {
background-color: #ffffff;
border-collapse: collapse;
border: 0px solid #aca899;
}
th {
text-align: left;
background-color: #ece9d8;
border: 1px solid #aca899;
padding: 2px;
}
td {
background-color: #ffffff;
text-align: left;
......@@ -67,16 +74,13 @@ td {
border: 0px solid #aca899;
padding: 2px;
}
ul, ol {
list-style-position: outside;
padding-left: 20px;
}
li {
margin-top: 2px;
}
</style>
</head><body>
......@@ -86,56 +90,66 @@ li {
<div style="float:left; margin:5px; width:320px;">
<h2>Using H2</h2>
<ul><li>H2 is open source, free to use and distribute.
</li><li>Download the
<a href="http://repo1.maven.org/maven2/com/h2database/h2/1.1.111/h2-1.1.111.jar">jar file</a>,
<a href="http://www.h2database.com/h2-setup-2009-04-10.exe">Windows installer</a>, or
<a href="http://www.h2database.com/h2-2009-04-10.zip">zip file</a>.
</li><li>To start the H2 Console tool, double click the jar file, or run <code>java -jar h2*.jar</code>, <code>h2.bat</code> or <code>h2.sh</code>.
</li><li>A new database is automatically created if it does not yet exist.
</li><li>Closing the last connection closes a database.
<ul><li><a href="http://h2database.com">H2</a> is
<a href="http://code.google.com/p/h2database/source">open source</a>,
<a href="license.html">free to use and distribute</a>.
</li><li><a href="http://h2database.com/html/download.html">Download</a>:
<a href="http://repo1.maven.org/maven2/com/h2database/h2/${version}/h2-${version}.jar" class="link">jar</a>,
<a href="http://www.h2database.com/h2-setup-${versionDate}.exe" class="link">installer (Windows)</a>,
<a href="http://www.h2database.com/h2-${versionDate}.zip" class="link">zip</a>.
</li><li>To start the
<a href="quickstart.html#h2_console">H2 Console tool</a>, double click the jar file, or
run <code>java -jar h2*.jar</code>, <code>h2.bat</code>, or <code>h2.sh</code>.
</li><li><a href="tutorial.html#creating_new_databases">A new database is automatically created</a>
<a href="features.html#database_only_if_exists">by default</a>.
</li><li><a href="features.html#closing_a_database">Closing the last connection closes the database</a>.
</li></ul>
<h2>Database URLs</h2>
<h2>Documentation</h2>
<p>
<b>Embedded</b><br />
Reference:
<a href="grammar.html" class="link">SQL grammar</a>,
<a href="functions.html" class="link">functions</a>,
<a href="datatypes.html" class="link">data types</a>,
<a href="tutorial.html#command_line_tools" class="link">tools</a>,
<a href="../javadoc/index.html" class="link">API</a>
<br />
<a href="features.html">Features</a>:
<a href="tutorial.html#fulltext" class="link">fulltext search</a>,
<a href="features.html#file_encryption" class="link">encryption</a>,
<a href="features.html#read_only" class="link">read-only</a>
<a href="features.html#database_in_zip" class="link">(zip/jar)</a>,
<a href="tutorial.html#csv" class="link">CSV</a>,
<a href="features.html#auto_reconnect" class="link">auto-reconnect</a>,
<a href="features.html#triggers" class="link">triggers</a>,
<a href="features.html#user_defined_functions" class="link">user functions</a>
</p>
<h2><a href="features.html#database_url">Database URLs</a></h2>
<p>
<b><a href="features.html#connection_modes">Embedded</a></b><br />
<code>jdbc:h2:~/test</code> 'test' in the user home directory<br />
<code>jdbc:h2:/data/test</code> 'test' in the directory /data/<br />
<code>jdbc:h2:test</code> in the current(!) working dir<br />
<code>jdbc:h2:/data/test</code> 'test' in the directory /data<br />
<code>jdbc:h2:test</code> in the current(!) working directory<br />
</p><p>
<b>In-Memory</b><br />
<b><a href="features.html#in_memory_databases">In-Memory</a></b><br />
<code>jdbc:h2:mem:test</code> multiple connections in one process<br />
<code>jdbc:h2:mem:</code> unnamed private; one connection<br />
</p><p>
<b>Server Mode</b><br />
<b><a href="tutorial.html#using_server">Server Mode</a></b><br />
<code>jdbc:h2:tcp://localhost/~/test</code> user home dir<br />
<code>jdbc:h2:tcp://localhost//data/test</code> absolute dir<br />
<a href="tutorial.html#using_server">Server start</a>:<code>java -cp *.jar org.h2.tools.Server</code>
</p><p>
<b>Settings</b><br />
<code>jdbc:h2:..;MODE=MySQL</code> compatibility (or HSQLDB,...)<br />
<code>jdbc:h2:..;TRACE_LEVEL_FILE=3</code> log to *.trace.db<br />
<b><a href="features.html#database_url">Settings</a></b><br />
<code>jdbc:h2:..;MODE=MySQL</code> <a href="features.html#compatibility" >compatibility (or HSQLDB,...)</a><br />
<code>jdbc:h2:..;TRACE_LEVEL_FILE=3</code> <a href="features.html#trace_options">log to *.trace.db</a><br />
</p>
<h2>Documentation</h2>
Reference:
<a href="http://www.h2database.com/html/grammar.html">SQL grammar</a>,
<a href="http://www.h2database.com/html/functions.html">functions</a>,
<a href="http://www.h2database.com/html/datatypes.html">data types</a>,
<a href="http://www.h2database.com/html/datatypes.html">tools</a>.
<br />
Features:
<a href="http://www.h2database.com/html/grammar.html">fulltext search</a>,
<a href="http://www.h2database.com/html/functions.html">database encryption</a>,
<a href="http://www.h2database.com/html/datatypes.html">read-only databases</a>
<a href="http://www.h2database.com/html/datatypes.html">(in a zip or jar file)</a>,
<a href="http://www.h2database.com/html/datatypes.html">CSV files</a>,
<br />
</div>
<div style="float:right; padding:5px; width:320px;">
<h2>Using the JDBC API</h2>
<h2><a href="tutorial.html#connecting_using_jdbc">Using the JDBC API</a></h2>
<pre>
Class.forName("org.h2.Driver");
Connection conn = DriverManager.
......@@ -143,7 +157,7 @@ Connection conn = DriverManager.
conn.close();
</pre>
<h2>Connection Pool</h2>
<h2><a href="tutorial.html#connection_pool">Connection Pool</a></h2>
<pre>
import org.h2.jdbcx.JdbcConnectionPool;
DataSource cp = JdbcConnectionPool.
......@@ -152,12 +166,7 @@ Connection conn = cp.getConnection();
conn.close(); cp.dispose();
</pre>
<h2>Start a Server</h2>
<pre>
java -cp h2*.jar org.h2.tools.Server
</pre>
<h2>Maven</h2>
<h2><a href="build.html#maven2">Maven 2</a></h2>
<pre>
&lt;dependency&gt;
&lt;groupId&gt;com.h2database&lt;/groupId&gt;
......@@ -166,7 +175,7 @@ java -cp h2*.jar org.h2.tools.Server
&lt;/dependency&gt;
</pre>
<h2>Hibernate</h2>
<h2><a href="tutorial.html#using_hibernate">Hibernate</a></h2>
hibernate.cfg.xml (or use the HSQLDialect):
<pre>
&lt;property name="dialect"&gt;
......@@ -174,9 +183,12 @@ hibernate.cfg.xml (or use the HSQLDialect):
&lt;/property&gt;
</pre>
<h2>TopLink and Glassfish</h2>
datasource classname: org.h2.jdbcx.JdbcDataSource<br />
oracle.toplink.essentials.platform.database.H2Platform
<h2><a href="tutorial.html#using_toplink">TopLink and Glassfish</a></h2>
<p>
Datasource class: <code>org.h2.jdbcx.JdbcDataSource</code><br />
<code>oracle.toplink.essentials.platform.</code><br />
<code>database.H2Platform</code>
</p>
</div>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论