openHAB2 & MySQL persistence setup

I have the same when i install JDBC Persistence MySQL and MySQL Persistence, i uninstalled JDBC Persistence and remove cfg file and it works. I do not know for what is JDBC Persistence when openhab2 works with MySQL Persistence.

… uninstalling JDBC Persistence MySQL didn’t chage anything in my case. If I call the sitemap/charts, Karaf displays some errors … thats it.

1 Like

… but it worked the other way around! I deleted mysql-service, installed jdbc and replaced mysql inthe sitemap with jdbc. Suddenly karaf became aware that it could’t find the tables and created them (items0001-0016). In the items table I’ve got ids and names!

… too bad that it’s not logging any data

Kind of figured it out.
First of all, I ended up using “just” mysql-Service, not jdbc-mysql, not both.
Naming the persitance-file *.persist insted of *.persistance got me the mysql-service creating the tables. I’ve got no idea why there were tables being created before at all … since my file had the wrong extension, but at least it’s now working as expected.

Best
Gerrit

Hello…
Followed the guide, but i get the following errors:

"mySQL: Connection not valid"
mySQL: tableName was null
mySQL: Could not create entry for 'Temp_Outside_South' in table 'Items' with statement 'INSERT INTO Items (ItemName) VALUES (?)': No operations allowed after connection closed.

But i don’t get any connection errors anymore, first it told me that password and user wasn’t okay - but after correcting this?
I only installed the MySQL - not the JDVC MySQL, as i can see that @gerrit says it isn’t nessecary?

When checking in the SQL database i can see that the table are created, one for Itemname and one for ItemID - but no data in them

UPDATE:
Uninstalled erverything, and only installed the JDBC-MySQL and the Addon for the JDBC (see guide here)

Also you need to make a jdbc.persist file - and not the mysql.persist
This worked for me

I have the problem, that I can only get charts for max. one day. Even if I set period=3d or =w, I only see the values of the last 24 hours displayed. In MariaDB I can see all old values from, e.g., last week.

Is there a way to get the older data also displayed in Chart?

Hi there,

never heard of this :frowning:
You are sure, that you defined period=3d ?
Try using period=w (week) …

Hi @Wurzelseppi

I figured out the problem after many days. I don’t know why, but (at least with MariaDB) I have to use “h, 4h, 12h” with a lowercase h but “D, 3D, W, M, 4M, Y” with capital letters. Then it works flawless. But if I use a small letter other than the h it won’t work.

Anyhow - now it does what I expected it to do. I replaced all with sed in my sitemap and voilà … all is good.

Is it OH2 or OH1?

It is OH2, installed via apt unstable repository (what I actually miss in Paper UI is a small text that indicates the installed version / build number):

[10:56:56] root@openhab:/etc/openhab2# apt-cache policy openhab2
openhab2:
  Installed: 2.1.0~20170212123642-1
  Candidate: 2.1.0~20170212123642-1
  Version table:
 *** 2.1.0~20170212123642-1 0
        500 http://dl.bintray.com/openhab/apt-repo2/ unstable/main armhf Packages
        100 /var/lib/dpkg/status
     2.1.0~20170210142723-1 0
        500 http://dl.bintray.com/openhab/apt-repo2/ unstable/main armhf Packages
     2.1.0~20170205135640-1 0
        500 http://dl.bintray.com/openhab/apt-repo2/ unstable/main armhf Packages
     2.1.0~20170204040936-1 0
        500 http://dl.bintray.com/openhab/apt-repo2/ unstable/main armhf Packages
     2.1.0~20170204005838-1 0
        500 http://dl.bintray.com/openhab/apt-repo2/ unstable/main armhf Packages
     2.1.0~20170203040910-1 0
        500 http://dl.bintray.com/openhab/apt-repo2/ unstable/main armhf Packages

I’ve updates the tutorial because I’ve figured out that both mySQL and mySQL.JDBC persistence didn’t work together anymore. In the recent releases (latest Snapshot Builds of OH2.1) I’ve got errors and it wasn’t working anymore. So I’ve uninstalled the JDBC persistence and commented out the configuration entries unter /Services/jdbc.cfg. Since I’ve had a mess in my mySQL DB, I’ve dropped all tables and restarted OB and everything got recreated.

I am a little lost her.
I would like to use mySQL as the central DB for persistence instead of multiple persitneces for different item types, but have some questions:

  1. I don’t need jdbc persistence mySQL, but only the “regular” mySQL persistence?
  2. Consecutively I need to modify mysql.cfg (and not jdbc), right?
  3. or the other way round (jdbc mySQL instead of mySQL in question 1 and 2?

I am using OH2 stable

Right, you need to have a MySQL Server somewhere, the "MySQL Persistence“ installed via PaperUI, a “mysql.cfg”(/etc/openhab2/services$) and “mysql.persist” (/etc/openhab2/persistence$) file.

Thanks a lot, Christian
I guess the two similar named are confusing. So it’s like:

mySQL persistence with a stand alone / separate mySQL server
vs
mySQL.JCDB persistence with a built in JCDB server (usiing mySQL datastructure)!?
Is this correctly summarized?

No, not really. You need a mysql server (either on another machine or on the machine running openHAB) and then you need either mysql or jdbc persistance to talk to the mysql server. In my experience jdbc persistance is the preferrable one, it has more configuration options. Mysql persistance is dedicated for only writing to mysql databases while jdbc persistance can write to various different databases, that’s the big difference.

alright - thanks for the clarification.
I will give it a try soon :slight_smile:

one more :wink:
in your latest post you prefer the jcdb.mySQL, but in your initial post, you are talking about the “regular” mySQL.
So you found out later, that jcdb.mySQL works better?
Sorry for this rookie question.
I just wanna make sure before I mess up my current setup :wink:

I’m not really sure which initial post you are referring to, I’ve only posted once in this thread :slight_smile:

But I guess there must be advantages with the mysql persistence over the jdbc one or else it wouldn’t have existed. Just I haven’t found them.

/Daniel

Damn it - you are right.
I just checked the response from Christian and I did not recognize, that you jumped in.
Sorry for that :wink:
Thanks for your help