[SOLVED] MySql Persistence: Value not saved after reconnection

I’am using the MySql persistance to log when someone entered my house using an rfid chip. For all other values I’am using an InfluxDB. The problem now is that when no one entered the house for some time the sql connection seams to be disconnected. The binding does reconnect to the database, but the value is still not stored after that. So I’am loosing the log every time a reconnect is done. Here are the logs:

2018-05-31 10:24:46.641 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Connection is not valid!
2018-05-31 10:24:46.649 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Connection is not valid!
2018-05-31 10:24:46.651 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Could not store item 'DoorLog' in database with statement 'INSERT INTO Item2 (TIME, VALUE) VALUES(NOW(),?) ON DUPLICATE KEY UPDATE VALUE=?;': No operations allowed after connection closed.
2018-05-31 10:25:15.580 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Connection is not valid!
2018-05-31 10:25:15.583 [ERROR] [sql.internal.MysqlPersistenceService] - mySQL: Error count exceeded 6. Disconnecting database.

After the complete disconnection it works again when the next log needs to be saved, but only until the next longer period when nothing is logged. Does anyone knows how the binding could be improved to solve this problem?

Change the waitTimeout parameter in the config file:

Thanks for the hint. The setting was set to 8 hours. I now set 48 hours. Maybe I will also add a dummy item that is updated every day so that the error doesn’t occur when I’m on vacation.

Please mark the thread as solved. Thanks