How can I keep my DB connection from failing when the network is unstable?

后端 未结 5 1788
攒了一身酷
攒了一身酷 2021-02-10 15:01

We have a application that uses BDE connected to an Oracle DB.
I use TQuery for the SQL queries, and it connects to TDatabase, we are not professional programmers, and we do

5条回答
  •  名媛妹妹
    2021-02-10 15:45

    Try to implement a "watchdog" thread that :

    1. Pings the network (IP address of the database server) every X seconds
    2. If unavailable then disables the UI and try to connect again

    Take into account that any transaction might not succeed at all, and save that information somewhere. Then, upon connecting via "watchdog" thread, try to preform that transaction again, if the nature of transaction allows so.

提交回复
热议问题