Subject Re: [IBO] Broken connection
Author Jason Wharton
> I made out-of-process server which keeps database connections alive
> all the time. But the problem is that during the night interbase
> server is shut down couple times a week for few hours.
>
> This causes connection error on Com server. I've tried catch
> an error in TIB_Database OnError event to close connection
> to interbase.
>
> So, What is the best way close connections and ping the server
> to reconnect properly to database.

There is a method to verify if the connection is still valid. I can't
remember what I called it but a browse of the methods for IB_Connection
should reveal it quickly.

When a connection is lost you have to explicitly call Disconnect and often
also explicitly Rollback transactions too. You then have to reconnect and
start work again. It is not possible to do a transparent reconnect because
InterBase will automatically rollback transactions of lost connections.

Also, never call Disconnect in an OnError event handler. Set a flag and
allow the exception to be raised. Then, in your application, catch the
exception and handle it there, where it is safe to call Disconnect.

HTH,
Jason Wharton
CPS - Mesa AZ
http://www.ibobjects.com