[SOLVED] MySQL vs JDBC MySQL (and restoreOnStartup)

Thanks @Benjy!

I changed jdbc.persist from:

* : strategy = default, restoreOnStartup

to:

* : strategy = everyUpdate, restoreOnStartup

and restarted OH2… and guess what… restoration of values took place! And, of course, the persisted/restored values are returned when I request the respective item states via the rest api.

For anyone else who might be trying to troubleshoot this kind of thing, before restarting, I enabled DEBUG level logging for org.openhab.persistence and org.openhab.persistence.jdbc, and I saw the following happening in the logs while running tail -f /var/log/openhab2/*. You can clearly see each query to restore the persisted value in openhab.log, immediately followed by the event changing from NULL to the expected value in the events.log.

==> /var/log/openhab2/openhab.log <==
2016-11-22 15:52:57.754 [DEBUG] [jdbc.internal.JdbcPersistenceService] - JDBC::query: item is time_sunrise
2016-11-22 15:52:57.756 [DEBUG] [persistence.jdbc.internal.JdbcMapper] - JDBC::getHistItemFilterQuery filter='true' numberDecimalcount='3' table='time_sunrise_6' item='time_sunrise (Type=NumberItem, State=Uninitialized)' itemName='time_sunrise'
2016-11-22 15:52:57.758 [DEBUG] [nhab.persistence.jdbc.db.JdbcBaseDAO] - JDBC::getHistItemFilterQueryProvider filter = org.openhab.core.persistence.FilterCriteria@18dfc30, numberDecimalcount = 3, table = time_sunrise_6, simpleName = time_sunrise
2016-11-22 15:52:57.759 [DEBUG] [nhab.persistence.jdbc.db.JdbcBaseDAO] - JDBC::query queryString = SELECT time, value FROM time_sunrise_6 ORDER BY time DESC  LIMIT 0,1
2016-11-22 15:52:57.760 [DEBUG] [nhab.persistence.jdbc.db.JdbcBaseDAO] - JDBC::doGetHistItemFilterQuery sql=SELECT time, value FROM time_sunrise_6 ORDER BY time DESC  LIMIT 0,1
2016-11-22 15:52:57.766 [DEBUG] [nhab.persistence.jdbc.db.JdbcBaseDAO] - JDBC::ItemResultHandler::handleResult getState value = '2.4394E7', getClass = 'class java.lang.Double', clazz = 'Double'
2016-11-22 15:52:57.768 [DEBUG] [jdbc.internal.JdbcPersistenceService] - JDBC::query: query for time_sunrise returned 1 rows in 12 ms

==> /var/log/openhab2/events.log <==
2016-11-22 15:52:57.787 [ItemStateChangedEvent     ] - time_sunrise changed from NULL to 24394000

==> /var/log/openhab2/openhab.log <==
2016-11-22 15:52:57.789 [DEBUG] [jdbc.internal.JdbcPersistenceService] - JDBC::query: item is time_sunset
2016-11-22 15:52:57.790 [DEBUG] [persistence.jdbc.internal.JdbcMapper] - JDBC::getHistItemFilterQuery filter='true' numberDecimalcount='3' table='time_sunset_7' item='time_sunset (Type=NumberItem, State=Uninitialized)' itemName='time_sunset'
2016-11-22 15:52:57.791 [DEBUG] [nhab.persistence.jdbc.db.JdbcBaseDAO] - JDBC::getHistItemFilterQueryProvider filter = org.openhab.core.persistence.FilterCriteria@429315, numberDecimalcount = 3, table = time_sunset_7, simpleName = time_sunset
2016-11-22 15:52:57.792 [DEBUG] [nhab.persistence.jdbc.db.JdbcBaseDAO] - JDBC::query queryString = SELECT time, value FROM time_sunset_7 ORDER BY time DESC  LIMIT 0,1
2016-11-22 15:52:57.793 [DEBUG] [nhab.persistence.jdbc.db.JdbcBaseDAO] - JDBC::doGetHistItemFilterQuery sql=SELECT time, value FROM time_sunset_7 ORDER BY time DESC  LIMIT 0,1
2016-11-22 15:52:57.796 [DEBUG] [nhab.persistence.jdbc.db.JdbcBaseDAO] - JDBC::ItemResultHandler::handleResult getState value = '5.8787E7', getClass = 'class java.lang.Double', clazz = 'Double'
2016-11-22 15:52:57.798 [DEBUG] [jdbc.internal.JdbcPersistenceService] - JDBC::query: query for time_sunset returned 1 rows in 8 ms

==> /var/log/openhab2/events.log <==
2016-11-22 15:52:57.800 [ItemStateChangedEvent     ] - time_sunset changed from NULL to 58787000

Thanks again!

1 Like