Storage / Embedded

H2

h2 component is used to inject h2 into Guice container. After the configuration is loaded, it can be used globally.

Feature

  • Support h2 version

How to use

<dependency>
    <groupId>io.edurt.gcm</groupId>
    <artifactId>gcm-h2</artifactId>
    <version>[1.1.0, )</version>
</dependency>

Warning: >= 1.2.0 has been replaced with the following usage


<dependency>
    <groupId>io.edurt.gcm.storage</groupId>
    <artifactId>gcm-storage-h2</artifactId>
    <version>[1.2.0, )</version>
</dependency>

Add the above configuration information to the pom.xml Reload the download dependency information in the file.

Configuration

To configure the h2 connector, create a catalog properties file in conf/catalog/h2.properties named, for example, h2.properties, to mount the h2 connector as the h2 catalog. Create the file with the following contents, replacing the connection properties as appropriate for your setup:

jdbc.h2.driverClassName=org.h2.Driver
jdbc.h2.url=jdbc:h2:./test
jdbc.h2.username=root
jdbc.h2.password=123
jdbc.h2.minimumIdle=10
jdbc.h2.maximumPoolSize=100
jdbc.h2.connectionTestQuery=select 1
jdbc.h2.cachePrepStmts=true
jdbc.h2.prepStmtCacheSize=250
jdbc.h2.prepStmtCacheSqlLimit=2048
jdbc.h2.useServerPrepStmts=true
jdbc.h2.scan.mapper.package=io.edurt.gcm.h2.mapper
Name Description Default
jdbc.h2.url h2 connection server connection string, need to carry database information jdbc:h2:./test
jdbc.h2.username User name to connect to h2 service root
jdbc.h2.password Password to connect to h2 service 123
jdbc.h2.minimumIdle - 10
jdbc.h2.maximumPoolSize - 100
jdbc.h2.connectionTestQuery - select 1
jdbc.h2.cachePrepStmts - true
jdbc.h2.prepStmtCacheSize - 250
jdbc.h2.prepStmtCacheSqlLimit - 2048
jdbc.h2.useServerPrepStmts - true
jdbc.h2.scan.mapper.package Scan the mapper file for the specified source directory io.edurt.gcm.h2.mapper

Example

String path = "/etc/conf/catalog/h2.properties";
Injector injector = Guice.createInjector(new h2Module(path));

Warning: path The absolute path of the configuration file, usually conf/catalog/h2.properties

Available annotation

  • @H2Source: It is used to distinguish the data sources used in the case of multiple sources
arrow_back

Storage / Embedded

Derby

Read previous doc
arrow_forward

Storage / Embedded

SQLLite

Read next doc