MySQL persistence empty database

Hello,

I’m using Nikobus with openhab, and want to log everything in a MySQL-database.
I did all the configurarion.
After starting the openhab-server, I had an error that OpenHab could not connect toe the database, so I created it manualy.
Than evertying was OK, but the only table that was created was ‘Items’ with the fields 'ItemId and ‘ItenName’ but the database is and stays empty.
Do I miss someting in the configuration?

Thanks,
Marc

It looks like MySQL is probably working as it’s created the database. The items tables are created only when data is first persisted for a particular item - have you configured up the mysql.persist file to actually enable persistence?

Chris

Chris,

This is my mysql.persist file

// persistence strategies have a name and a definition and are referred to in the "Items" section
Strategies {
    everyHour : "0 0 * * * ?"
    everyDay  : "0 0 0 * * ?"

        // if no strategy is specified for an item entry below, the default list will be used
        default = everyChange
}

items {
        // persist all items once a day and on every change and restore them from the db at startup
        // careful, this might result in huge databases - that's why it is in comment here ;-)
        * : strategy = everyChange, everyDay, restoreOnStartup

        // persist all temperature and weather values at every change and every hour
       // * : strategy = everyChange, everyHour
}

I was thinking that so it logs everything.

Thanks,
Marc

Looks ok I think - it’s very similar to what I’m using…

I guess the next step is to look in the debug log to see it anything is showing up there… The mySQL service logs quite a lot of data, so it’s worth checking the logs to see if there’s any information…

Chris

Chris,

I don’t have errors in my debug-log-file…
Any other ideas?

Thanks,
Marc

Is there anything from the mysql service logged in the log file? If not, that might indicate that the persistence service isn’t being called by the persistence manager. Do you get a message saying that it’s reading the mysql.persist model file?

I have these lines in the log-file

10:58:45.739 [INFO ] [c.internal.ModelRepositoryImpl:80   ] - Loading model 'mysql.persist'

10:58:50.302 [DEBUG] [sqlPersistenceServiceActivator:32   ] - mySQL persistence bundle has been started.
10:58:50.314 [DEBUG] [.p.m.i.MysqlPersistenceService:500  ] - mySQL configuration starting
10:58:50.315 [DEBUG] [.p.internal.PersistenceManager:147  ] - Initializing mysql persistence service.
10:58:50.316 [DEBUG] [.p.m.i.MysqlPersistenceService:427  ] - mySQL: Attempting to connect to database jdbc:mysql://127.0.0.1/openhab
10:58:50.330 [DEBUG] [.p.internal.PersistenceManager:441  ] - Scheduled strategy mysql.everyHour with cron expression 0 0 * * * ?
10:58:50.332 [DEBUG] [.p.internal.PersistenceManager:441  ] - Scheduled strategy mysql.everyDay with cron expression 0 0 0 * * ?

Chris,

I found the problem in the persistence-file.
I used ‘Items’ instead of ‘items’, and now it’s working. So it’s case-sensitive…

1 Like

Interesting - thanks :smile:

I’m sure someone will point out that you should have used the designer as it would probably have syntax checked this for you (but it won’t be me, since I also don’t use it :smile:)

Thanks a lot, was searching the issue in my conf for hours !

Hey,

I have the same problem: no data is written to the database.
No error in any logs an openhab has created an empty tamble ‘items’

Looking at my mariadb.persist I used an
Items, like its written in the doc.
If I change this to items, so i get the following error: missing EOF at 'items'

I would like to give an answer, what my problem was, in case an other user has the same problem:

1.) there was no data written to database, because the config was located in an file named mariadb.persist, but the name of the persist-file should be match to the name of the uses persistence add-on. In my case: jdbc, which means, the config file should be named: jdbc.persist

2.) there was an syntax error in the file. I never found that error, but build up this file from scratch

2 Likes

Tanks B0rner!! This was it!!! You saved hours of my life