Deal with bad connections

Deal with bad connections

Postby Zod » Mon 27 Apr 2015 08:31

Hello,

we use

dbxida42.exe filedate 7.6.12 with version dbexpida.dll ist 4.2.3.0 17.5.2013

in our application programed in Delphi7.

Here we use a descendat of TSQLDataSet to deal with our Firebird DB (Server version: WI-V6.3.2.26539 Firebird 2.5). With initialising our application the user logs into the database - so that SQLConnection.Connected is set to true until the user loggs out.

The standard process to get data is
- define a query in SQLDataset.CommandText
- prepare the SQLDataset
- set the SQL parameters in the SQLDataset
- set SQLDataset.Active := True
- set Active := True in an ClientDataSet (connected via TDataSetProvider to the SQLDataSet)
- set SQLDataset.Active := False

We use the CDS in the application and so we try to minimize the time where the connection to the database is used for datatransfer.

Our problem is:
due to somtimes bad WLan connection we loose the contact to the DB. That kills our application. The extended driver options "reconnect" is left to the default value (True).

My question is:
is there a way to "check" within the TSQLConnection scope, that the connection to the db is working befor a query is sent to the db. Or is there a way to do this within our
SQLDataSet (e.g. in BeforeOpen).

Thanks for any suggestion here.
Zod
 
Posts: 2
Joined: Mon 27 Apr 2015 07:54

Re: Deal with bad connections

Postby ViktorV » Mon 27 Apr 2015 11:36

When the database server is shuts down, the clients connected to it don't know about that. Therefore the only way to detect connection loss is an attempt to execute any operation on the server. In case of an error, an exception is generated, which you can handle.
Please pay attention, that if connection is lost and the Reconnect option of the driver is set to True, dbExpress driver for InterBase and Firebird attempts to reconnect - and only after 3 attempts it generates an error.
ViktorV
Devart Team
 
Posts: 1833
Joined: Wed 30 Jul 2014 07:16

Re: Deal with bad connections

Postby Zod » Mon 27 Apr 2015 11:51

Sorry - maybe the wording of my question was not complete, I must ask a bit more.

So - which components throws the exception in case of a loss of the conntection to the DB server and how can I catch this exception (the TSQLConnection has no "OnException" event)?

As I wrote the point are bad wifi connections. So my idea is to restore the wifi conection befor firing the query maybe again to the db server. This would be easy at the point where all db data is handled: in the SQLConnection. But I cannot see how to implement this.

So is it possible to interact with the dbExpress driver in order to manage the wifi connection issue within the reconnect cycle of the driver?

Any suggestions are welcome, many thanks in advance.
Zod
 
Posts: 2
Joined: Mon 27 Apr 2015 07:54

Re: Deal with bad connections

Postby ViktorV » Mon 27 Apr 2015 13:13

The restrictions applied by the dbExpress technology to our driver don't allow to implement the required functionality.
You can organize server availability check by yourself. For example:
Code: Select all
  SQLQuery.SQL.Text := 'select * from RDB$DATABASE';
  try
    ClientDataSet.Open;
  except
    on E: Exception do
      ShowMessage('Error connection: ' + E.Message);
  end;
ViktorV
Devart Team
 
Posts: 1833
Joined: Wed 30 Jul 2014 07:16


Return to dbExpress driver for InterBase & Firebird