Forum > Database

Zeos - TZquery, catch lost connection ?

(1/2) > >>


Hello !

I have many opened Tzquery components working with a TZconnection, and if the connection is lost, I would like to connect back to the database, without showing "error writing to DB....".

Do you know if there is a way to globally catch a database disconnection with zeos ?

Have I to check Tzconnection.pingserver each time I do a request with a TzQuery?

Many thanks to you all !

The upcomming Zeos Version 8 as a connection Event "OnLost".

If this event is triggered, all objects are closed than. IMO Only choice is to reopen all datasets if you can reconnect. Pinging the servers would only help to find out if you CAN reconnect. Connection loss can happen everythime, while reading, writting, commit etc. So continue work, without refreshing everything (except loaded+cached datasets) won't be possible.

Thanks for your reply.
Is there at least a way to catch the writing error when a connection is dropped with visual components ? and then close all datasets, reconnect and re-open them ?

A writing error can't be explicitly determined. According the Components:
Yes, it is but you don't need todo anything by hand. IIRC if a "connection loss" is triggered, all datasets, sequence-componenents, listeners, transaction-components, streams getting closed immediately. Finally you'll get a Conenction lost exception. If the Event is not assigned.
I've to correct myself: Pinging the server won't be possible anymore because the handles are flushed. But you can use the pings as something like "keep alive" packages to prevent disconnect timeouts. Click download snapshot.

I installed svn version, and everything seems to work well. I didn't try to use Onlost, I will do it later.
I have this error that appears while I try to use CreateBlobStream(FieldByName(...), bmread)
It worked well before. Is this a bug ? How could I get the stream?
Regards !


[0] Message Index

[#] Next page

Go to full version