[fpc-devel] Death of TSQLConnection instance after connection interrupt
Michael Van Canneyt
michael at freepascal.org
Fri Apr 17 10:42:03 CEST 2015
On Fri, 17 Apr 2015, Чернов Дмитрий wrote:
> Recently I've used FPC with SQLdb that is included in latest Lazarus. And after some usage I've determined one inconvience: if connection to database server of instance of
> TSQLConnection (or it's descendant) will be interrupred, instance will fall into a coma. This happens because of some reasons:
> 1) there is no way to determine whether connection is broken
> 2) no exceptions are thrown on connection interrupt
> 3) none of disconnection events are called on interruption
> 3) if you'll try to shutdown interrupted connection by setting Connected property of TSQLConnection to False, you will get exception about interrupted connection and after that...
> property value will not be changed. so, you can't reconnect.
> So, due to this reasons, currently there is only single way to raise the connection - manually re-create TSQLConnection component instance in run-time, what awful.
> It seems that my english is entirely terrible, so excuse me in advance.
We are aware of this problem, and we are working on a solution to be able to reconnect (so, point 4 in your list (actually, the second 3) :))
See for example: http://bugs.freepascal.org/view.php?id=26505
There is a beginning of a patch in TCustomConnection
procedure Close(ForceClose: Boolean=False);
if you set Force to True then the connection will be closed and errors will be ignored.
More information about the fpc-devel