Author Topic: Auto reconnect to MySql database  (Read 300 times)


  • New member
  • *
  • Posts: 7
Auto reconnect to MySql database
« on: September 19, 2020, 03:51:34 pm »
Hello all!

I`m making program working with MySql database. It may works for a long time without any activity and sometimes connection may be closed by server with wait timeout.

I created some demo with trying to implement automatic reconnect feature before data has been send to the server. I forcibly set the mysql variable 'set_timeout' to 10 seconds. In SQLQuery`s BeforeDelete and BeforeEdit events I check status of current connection and if it closed, create it again.

Issue is that insert and update don`t work after reconnect.
Insert error:

Update error:

If connection is still alive, these actions forks fine.

Lazarus: 1.6, FPC: 3.0.0, OS: Windows 7 64 bit


TinyPortal © 2005-2018