openHABian JDBC setup (mySQL, mariaDB)

I am trying to establish persistence with JDBC on a Raspbery Pi 3 and openHABian. Used both Bindings for mySQL and mariaDB. In the log is always displayed, that the JDBC driver is missing (JDBC::openConnection: no driver available!). I found them in the /srv/openhab-userdata/tmp folder. I also generated mariadb.cfg / mysql.cfg in the /etc/openhab2/services folder.

Example /etc/openhab2/services/mariadb.cfg:

url=jdbc:mariadb://192.168.2.xxx:3306/openhab
user=openhabian
password=xxx

Also set up the mariadb.persist (or mysqldb.persist). But nothing happening.
Database is reachable from foreign hosts (tested with the clients on notebook command line). But no tables where created.

Can somebody help? I read much articles about this topic. But there seams to be a great difference between openHAB 1 & 2 according to this and everything works a little bit different on the openHABian installation (spreaded folders). I guess the driver is in the wrong destination.

First: mariadb.cfg. There is no mariadb binding nor a mariadb persistence service. You could use mysql persistence with mysql.cfg instead, but I’m pretty sure the driver is named mysql, not mariadb (at least I use MariaDB sucessfully since ~ OH 1.2 with mysql driver)

Second, since there is no such persistence service as mariadb, a file named mariadb.persist would have no effect. And as there is no mysqldb persistence either, but only a mysql persistence, file file must be named mysql.persist for this persistence.

Third, you can use jdbc persistence instead of mysql persistence, but then you have to use jdbc.cfg and jdbc.persist

Please read the manual :wink: http://docs.openhab.org/addons/persistence/jdbc/readme.html and http://docs.openhab.org/addons/persistence/mysql/readme.html attentive.

As the persistence services are all(!) OH1.10, I doubt there are any changes between OH1 and OH2.

Hello Udo,

thanks for your statement. But now I am confused:

I have a MariaDB-Binding in openHABian2. But I will try again with your suggestions of file-naming (and mysql).

What I learned now, that the naming is even more important than I thought. Can I derive the names from something (e. g. the from then Binding-Name persistence-jdbc-mariadb - 1.10.0 or persistence-jdbc-mysql - 1.10.0)? Sometimes I’m lost with the thin documentation and the differences from the versions 1 & 2 (sometimes not clear in web articles).

1 Like

No, that is the JDBC Persistence with MariaDB driver! Therefor, you have to follow the instructions for JDBC, so please use

jdbc.cfg (should be already in services/ !) and
jdbc.persist

Thanks. That was my rescue. So it is not possible to maintain more than one JDBC-persistence-service if there is only one configuration file?

I’m pretty sure that is correct.

To be honest, I don’t know, why to use more than one (SQL) database system on the same openHAB system, but at least one could use mysql persistence in addition to another (even mysql, or any other) jdbc driven database.

jdbc persistence makes it easy to change the database backend without changing any openHAB configuration (aside from modified driver connection).