MySQL connection through JDBC persistence fundamentals


I currently have Openhab2 up and running with a MySQL server and the JDBC persistence downloaded.
I modified /etc/openhab2/services.cfg and created also a mysql.persist file, but still I am missing some basic information about how all this is working together, in order to test my application. Is there help/can some provide help on below topics?

• How can I check if my database connection between OpenHab2 and Mysql is successful? (By logfile? By direct URL? By loading a widget in the openhab panel?)
• Where in Openhab2 do I specify to which database table it should connect?
• How are different columns from a table converted into items?
• How can I query (select) the database from Openhab2?

Does anyone have answer to these basic questions? (or sample project)
Maybe these answers can be added to the tutorial later on.

Thanks, Bert


if you only want to use mySQL, I would suggest using the mySQL binding for it. Pretty easy and straigthforward to set up.
As for setting the whole thing up(Database side and OH side), you should read up here:
and for detailed instructions for differnt OSes here:

For Maintenance of my DB i use phpMyadmin. This and other tools are just one Google search away.

Probably by looking in the log file. You should see some errors in the log with “mysql” in the name of the source (part in [ ]).

You don’t. OH creates its own tables. You specify which DB and credentials in mysql.cfg.

I can’t answer this. But given that it creates its own tables and columns this hasn’t come up on the forum (I use InfluxDB).

See the Persistence in Scripts section of the Persistence docs.

Documentation on persistence is TBD in the Beginner’s Tutorial. It’s in the plan.

Thanks for your feedback. I see some tables are created now, but still do not understand to which items they belong, or how I can change their name. They should belong to active items because the tables are filled up I can see.

The mapping Item Name/Table name is done in Table "Items"
However, you should never, under no circumstance, change the Table names. This will most likely break your persistence.

1 Like