Set up persistence - nothing are persisted to database table

Tags: #<Tag:0x00007f616f27a1a0> #<Tag:0x00007f616f279fc0> #<Tag:0x00007f616f279e08>

Hi

I’m trying to get persistence to work with my newly created openhab2 binding. I have tried to follow this tutorial someone else had made. --> openHAB2 & MySQL persistence setup

So I did what it told me to do but still are not receiving any data in the table.
Have installed mysql on my own computer and connected to the server where the mysql openhab is installed. Here I see the table Items but no data in it when doing a select * from Items.

My “mysql.persist” file

// persistence strategies have a name and a definition and are referred to in the "Items" section
Strategies {
// if no strategy is specified for an item entry below, the default list will be used
everyMinute	: "0 * * * * ?"
every5Minutes : "0 */5 * * * ?"
everyHour   : "0 0 * * * ?"
everyDay    : "0 0 0 * * ?"
default = everyChange
}

/* 
 * Each line in this section defines for which item(s) which strategy(ies) should be applied.
 * You can list single items, use "*" for all items or "groupitem*" for all members of a group
 * item (excl. the group item itself).
 */

Items {
// persist all items once a day and on every change and restore them from the db at startup
* : strategy = everyChange, everyDay, restoreOnStartup

My “mysql.cfg”

# the database url like 'jdbc:mysql://<host>:<port>/<database>' (without quotes)
url=jdbc:mysql://127.0.0.1:3306/OpenHAB2

# the database user
user=openhab2

# the database password
password="my password"

# the reconnection counter
#reconnectCnt=

# the connection timeout (in seconds)
#waitTimeout=

# Use MySQL Server time to store item values (=false) or use openHAB Server time (=true).
# For new installations, its recommend to set "localtime=true".
# (optional, defaults to false)
#localtime=true

And yes the mysql server is installed on the same linux server as openhab2.
And yes I have tried restarting the openhab2 service.

Hope someone can help

Just two minor observations (I’m not a persistence expert…):

  1. The closing brace of the items section in mysql.persist is missing (maybe only omitted from your post)
  2. In addition to these files I have edited the addons.cfg. In that file I have uncommented the persistence= line and added my persistence service (in my case not mysql but mariadb though):

persistence = jdbc-mariadb

I am not sure if one of these observations might help.

It is not required to set mysql as the default to have it store the values as defined in the .persist file.

Assuming that the .persist file is not missing the curly brackets, does anything change if you list one or two specific Items instead of *?

Do you see anything in the logs that might indicate a problem with OH connecting to the DB or otherwise? The fact that the Items table exists at all implies no but we need to rule that out as an issue.

I’m limited in my experience with MySQL and other similar persistence DBs (I use InfluxDB) so I’m not sure how much overall help I can be.

Thanks both for your suggestions. It turned out it was the curly bracket :frowning: So typically.