-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
JDBC persistence puts everything in the same table #5112
Comments
Could you add the contents of your jdbc.cfg, redacting any private information? |
This is the complete file (minus all empty rows and rows starting with #): url=jdbc:mysql://127.0.0.1:3306/openhab |
@lewie would you have any comments on this? |
Two details after some investigation of the table (no idea if they're of any use at all):
|
Some snippets from debug logging: `07:30:00.055 [DEBUG] [persistence.jdbc.internal.JdbcMapper] - JDBC::storeItemValue: item=Motorvarmare_Switch (Type=SwitchItem, State=OFF) 09:03:10.423 [DEBUG] [persistence.jdbc.internal.JdbcMapper] - JDBC::storeItemValue: item=ZWaveMultiSensor_SensorTemperature (Type=NumberItem, State=4.6) |
You should really upload the full log. |
Doh. I thought that in order to really be able to give you a clean good log I'd simply stop the persistence bundle, clear the database and start the bundle again to get exactly what happened when trying to create the tables in the log. Only this time it worked... I guess something must have gone wrong when it first tried to make the tables. Do you want to dig deeper into it or should we just close the issue? |
I think we should hold this open a while longer and see what the database/persistence expert can grok from it. He might have a theory as to what went wrong. |
Righty then. I did some log diggging and realized that I actually had debug logging on for jdbc when I first activated it, so there's quite much interesting in the log. My best guess is that (for some reason) it failed creating the "items" table which then led to the other problems. Pasted relevant part of log here: http://pastebin.com/raw/wZ5h2pqn |
@DanielMalmgren, groked now... ;-) What means
Dir you delete all Tables? Or do you want to migrate from Mysql bundle with empty tables? As I can see, from
After that line anything is wrong in your Database Layout (see mine at the end) Your configuration seams perfect. But a item0000-table never is generated by openHAB jdbc! First Table is a Table named items (where all Item names are stored). I installed a new OH2 with two Items used new Database with Collation utf8_general_ci:
|
I did a drop database followed by a create database, so it was really completely empty. What I'm thinking is that I might have been stupid enough to first change default persistence to jdbc and then wiping the database right when it was in the middle of initializing stuff. Could that have caused this? I haven't looked at the code, but it kinda feels like an int variable was supposed to hold the number of the table to put values in and this variable never got initialized and thus was always zero (causing the item0000). |
Yes definitely! Do this now:
Then everything should init right. |
Well, if you read my comment (number eight from the top) that's about what I already did, so the problem is already solved for me :-) This issue is still open only because of the possibility of finding a bug somewhere... |
@DanielMalmgren, OK yes, hmm, to solve this, jdbc bundle would have to delete other tables if items-table does not exist. Think about to catch this. Thanks. |
Expected Behavior
A database with one table per persisted Item.
Current Behavior
A database with one single table named item0000 where values from all persisted items seems to end up.
No relevant errors in the log as far as I can find.
Possible Solution
Steps to Reproduce (for bugs)
Context
I used MySQL persistence before, didn't have this problem there. Using the same database (did a complete wipe of it though).
The only thing I changed in jdbc.cfg (except for url, user and password) was numberDecimalcount which I set to 1.
Your Environment
The text was updated successfully, but these errors were encountered: