H2 Plugin
---------

Supports direct access to a H2 database.

H2 is the second generation of HSQL, a popular embedded Java database. The current database is not
a true spatial database as it does not have any form of spatial indexing.

**Maven**
   
Note that the ``groupId`` is ``org.geotools.jdbc`` for this and other JDBC plugin modules.

::

   <dependency>
      <groupId>org.geotools.jdbc</groupId>
      <artifactId>gt-jdbc-h2</artifactId>
      <version>${geotools.version}</version>
    </dependency>

Connection Parameters
^^^^^^^^^^^^^^^^^^^^^

+---------------+----------------------------------------------+
| Parameter     | Description                                  |
+===============+==============================================+
| ``dbtype``    | Must be the string ``h2``                    |
+---------------+----------------------------------------------+
| ``database``  | The database to connect to                   |
+---------------+----------------------------------------------+
| ``user``      | User name                                    |
+---------------+----------------------------------------------+

Creating
^^^^^^^^

Here is a quick example:

.. literalinclude:: /../src/main/java/org/geotools/jdbc/JDBCExamples.java
   :language: java
   :start-after: // h2Example start
   :end-before: // h2Example end

The above will reference a database file named ``geotools`` located in the current working directory. 
A full path may also be specified:

.. literalinclude:: /../src/main/java/org/geotools/jdbc/JDBCExamples.java
   :language: java
   :start-after: // h2AbsPathExample start
   :end-before: // h2AbsPathExample end
   
The above examples create a connection to H2 in *embedded* mode. One limitation to this approach is 
that it only allows for a single Java process to access the database at any one time. H2 also offers 
a `server mode <http://www.h2database.com/html/tutorial.html#using_server>`_ in which access
to the underlying database is made via traditional client-server TCP connection, and removes the embedded
single process restriction:

.. literalinclude:: /../src/main/java/org/geotools/jdbc/JDBCExamples.java
   :language: java
   :start-after: // h2TcpExample start
   :end-before: // h2TcpExample end
