H2DatabaseTCPServer

This module is a part of the NetHomeServer. The H2DatabaseTCPServer connects with a local H2 TCP Database and will open up connectivity to store and read values from a H2 database.

The item is used in storing value item logs written by other home items such as thermometers and hygrometers. It is also used to retrieve data when viewing graphs from a home item.

H2 Database is integrated with NetHomeServer. A future version may support remote H2 Database instances.

See also discussion below on how to configure global logging to the database.

Displayed values

The readonly values displayed at the top shows the outcome of the configuration.

Note, the web connection string may show https for public access but you may still not be able to access the console. This is because the home item can't know if the SSL is enabled or not. If so, access the web console using http and preferably change via preferences to use SSL (Use encrypted SSL (HTTPS) connections).

Functions

Settings

These settings are available in the home item:

Note: You may have to stop and start the service(s) if you change any of the settings.

Configure global logging to the database

Following these steps will enable global logging of all value items to the database.

In this example the database will be named nhs_values and created with a user named sa and the password will be set to SuperSecretPa$$w0rd.

  1. Go to the Settings page and enter a GlobalLogger value as jdbc:h2:tcp:localhost/nhs_values;USER=sa;PASSWORD=SuperSecretPa$$w0rd
  2. Create the H2DatabaseServer home item. It is located in the Ports section. Fill in the fields as explained earlier on this page.
  3. Make sure the H2DatabaseServer is enabled

The Log view will display additional information about the logging activity.

Note! Always use a hard to guess password if you intend to have the Web console public.

The jdbc:h2:tcp: part is needed to enable the database functionality.

Change user and password

(Un)fortunately it is not easy to change the user name and password. If you need to do this, simply provide a new database name and new credentials. Re-import the text log files as is explained next.

Import text log files

There is an import function that will let NetHomeServer import every text log file of all home items into the database. It expects the home items to have a LogFile configured so that the file can be found, or otherwise the item will be skipped.

  1. Go to the Settings page and click the Update Global Logger button
  2. The import will start and it can take some time before all values have been imported.
  3. View and periodically refresh the Log page for progress of the import.

View graphs

When you want to view graphs of the logged data, click the View graph… link for home items.

Please note that the database server will cache the result on successive views. This means that the first view will take slightly longer but successive views will be faster. This is in any case several times faster than reading the logs from the text files.

See also

http://www.h2database.com/html/main.html