User Tools

Site Tools


h2databasetcpserver

This is an old revision of the document!


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.

Functions

  • Start and Stop TCP Service is for the H2 Database server itself.
  • Start and Stop Web Service is for the H2 web console itself.

Settings

These settings are available in the home item:

  • Item name is whatever name you would like to call the new item, for example “H2DatabaseServer”.
  • DatabasePath is the location on your NetHomeServer installation where H2 can access the database. Enter a “~” (tilde) character for the current users directory. On a Raspberry Pi installation (Linux) this is the user NetHome's directory at /home/nethome.
  • TCP active on startup when checked will activate the H2 database server on startup of NetHomeServer.
  • TCP Port is the internal port for accessing the H2 database console.
  • WEB active on startup when checked will activate the H2 web console on startup of NetHomeServer.
  • WEB Port is the public port for accessing the H2 web console.
  • WEB public when checked will make the H2 web console made available to the public - they will still have to log in though. If unchecked will only allow connections locally to the web console (on the same machine, localhost, 127.0.0.1, etc).

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. The database named nhs_values will be created with a user named sa and the password will be set to SuperSecretPa$$w0rd.

  • Go to the Settings page and enter a GlobalLogger value such as jdbc:h2:tcp:localhost/nhs_values;USER=sa;PASSWORD=SuperSecretPa$$w0rd
  • Create the H2DatabaseServer home item. It is located in the Ports section. Fill in the fields as explained previously
  • 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.

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.

See also

h2databasetcpserver.1457288336.txt.gz · Last modified: 2018/11/03 02:57 (external edit)