Consultor Eletrônico



Kbase P147806: How to trap a lost database connection
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   1/4/2010
Status: Verified

GOAL:

How to trap a lost database connection

GOAL:

How to detect if your database connection has been lost

GOAL:

What to do when CONNECTED() function returns true yet the database is NOT connected

FACT(s) (Environment):

Error <read/writing> socket, ret=<n>, errno=<n>. (778)
All Supported Operating Systems
Progress 9.x
OpenEdge 10.x

FIX:

Typically one uses the CONNECTED function to check for a database connection before executing a CONNECT statement to connect to a database. Under most normal situations this is adequate, however when a database connection is abnormally severed; whether because of a network failure or a disconnect request from the database itself, the best way to detect this disconnection is by creating a dynamic BUFFER object for a table in the database.


If the CREATE BUFFER statement fails no error is returned however the buffer handle is invalid. This is a pretty good sign that your database is not connected. The table you should create the buffer for should be one that is guaranteed to be in the database and the CREATE BUFFER statement should include the database name, as follows:


DEFINE VARIABLE hBuffer AS HANDLE NO-UNDO.


CREATE BUFFER hBuffer FOR TABLE "Sports2000._file".
IF NOT VALID-HANDLE(hBuffer) THEN
CONNECT Sports2000 ....