Skip to main content
Jump to: navigation, search

OM2M/one/Advanced DB

In this tutorial, you can configure the OM2M default database (H2) your way and, if needed, use an alternative system and set it up. (From now, database is referred as DB). By default, OM2M uses the H2 database through a persistence abstraction layer and a JPA (EclipseLink). H2 server is configured to run in an embedded mode and the database file is stored in the product directory (database/<file>).

If you are looking for more detailed information about H2 itself, check the H2 website and tutorials: [1]


  • OM2M project cloned and built

Modify the default configuration

In the following guidelines, the modified constants are located in the file. This file is located in the configuration folder in the product directory once you have cloned and built the project.

DB reset on startup

By default the DB is reset on startup of the platform that is to say data are deleted. To modify this configuration just change the following constant to false. This constant can be found in the config.ini file, in your product (IN, MN, etc.).


Use another User / password to access the DB

By default, the user and its password used to connect to the DB are "om2m". Of course you can use different user/pwd if you want to use another configuration for your persistence part. To change the user and its password, modify the two following constants:


Use a different location for DB file

To change the location of the DB file, you need to modify one constant in the config.ini file. (located in the configuration folder in the product (IN, MN, etc.). For the IN you have by default:


You can use any alternative path, just put it after the last ":" in the "jdbc\:h2\:" part like this:


Run H2 in another mode

By default H2 is embedded in OM2M and stores data into a file. You can set up H2 to run in server mode (classic) and configure OM2M to connect to this server, or even run H2 in memory (for gateways for instance) if needed.

Run H2 in memory

For limited gateways, you may want to configure H2 in memory mode to have a faster interaction. However be aware of possible loss of data in case of reboot or shut down of your gateway. This mode is interesting if you have few data stored in the gateway itself and have another instance that is safer. To use H2 in this mode just modify this constant in the config.ini file of your node:


Run a server and configure the connection

This solution may be useful if you want to have a dedicated machine that will be your DB server for your system.

Launch the DB server

To launch H2 in server mode, just download the version you want to use of H2 from H2 website: [2]. (The following example use the platform independant zip.) Unzip the file and go to the h2/bin directory. To launch the server without any complex configuration, just use:

java -jar h2*.jar

This operation will open a webpage about the web console. There you can manage your database, create users, etc. To know more details and possibilities about this part, please visit the H2 online tutorials: [3]

Configure OM2M to connect to the server

Just modify this constant in the config.ini file:


You can find other configurations on the H2 website: [4].

Back to the top