User Tools

Site Tools


h2databasetcpserver

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
h2databasetcpserver [2016/03/06 19:08] – [Change user and password] pelah2databasetcpserver [2018/11/03 02:59] (current) – external edit 127.0.0.1
Line 5: Line 5:
 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. 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.
  
-See also discussion below on how to configure the database for logging of value items.+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.
 +
 +  * **TCP ConnectionString** shows the internal address to the database server, for example //jdbc:h2:tcp:////10.0.1.40:9092/[data file name]//
 +  * **TCP Status** shows the status of the database server, for example //Running, remotes can connect//
 +  * **WEB ConnectionString** shows the address to the web console. Depending on the **WEB public** setting this value may show as http://10.0.1.40:8082 or http://127.0.1.1:8082 when not available publicly, or https://10.0.1.40:8082 public.
 +  * **WEB Status** shows the status of the web console, for example //Running, remotes can connect// or //Not running - check logs// if the server has not been started.
 +
 +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 ===== ===== Functions =====
Line 16: Line 27:
  
   * **Item name** is whatever name you would like to call the new item, for example "H2DatabaseServer".   * **Item name** is whatever name you would like to call the new item, for example "H2DatabaseServer".
-  * **DatabasePath** is the location on your 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.+  * **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 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.   * **TCP Port** is the internal port for accessing the H2 database console.
Line 25: Line 36:
 //Note: You may have to stop and start the service(s) if you change any of the settings.// //Note: You may have to stop and start the service(s) if you change any of the settings.//
  
-===== Configure global logging to the database ===== +====== 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 **sa**.+Following these steps will enable global logging of all value items to the database. 
  
-  * Go to the Settings page and enter a GlobalLogger value such as **jdbc:h2:tcp:////localhost/nhs_values;USER=sa;PASSWORD=sa** +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**. 
-  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+  - Go to the Settings page and enter a GlobalLogger value 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 earlier on this page. 
 +  Make sure the H2DatabaseServer is enabled
  
 The Log view will display additional information about the logging activity. 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 ===== ===== Change user and password =====
 (Un)fortunately it is not easy to change the user name 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. If you need to do this, simply provide a new database name and new credentials.
-Re-import the log files as is explained next. +Re-import the text log files as is explained next. 
-===== Import text logs =====+===== 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. 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. It expects the home items to have a **LogFile** configured so that the file can be found, or otherwise the item will be skipped.
Line 46: Line 62:
    - View and periodically refresh the Log page for progress of the import.     - 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 ==== ==== See also ====
 http://www.h2database.com/html/main.html http://www.h2database.com/html/main.html
h2databasetcpserver.1457287706.txt.gz · Last modified: 2018/11/03 02:57 (external edit)