Kbase P18439: How to handle gracefully problems connecting an AppServer server to a database.
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  16/10/2008 |
|
Status: Unverified
GOAL:
How to handle gracefully problems connecting an AppServer server to a database.
FIX:
When an AppServer agent tries to connect to a database at startup, but there is a connection problem, the AppServer agent will die and the AppServer broker itself will die once it recognises that no AppServer server actually started because of the server startup failure [PHRASE BETTER !!!]
The AppServer Connect procedure can help in this.
Connect procedures are executed each time a connection request, and are available in all three operating modes (stateless, state-aware, state-reset).
If the Connect procedure completes with no error, the connection request from the client application is accepted.
If the Connect procedure completes with an error (with a RETURN ERROR statement) or a STOP or a QUIT condition), the connection request is rejected.
Therefore it's possible to try to connect to a database via the CONNECT statement with the NO-ERROR option, and then do a RETURN ERROR if the database did not connect. This way, once a client connects to the AppServer via the CONNECT() method, all that will happen is that the CONNECT() method returns false.
/* connect.p */
.....
CONNECT -db myDatabase NO-ERROR.
IF ERROR-STATUS:NUM-MESSAGES > 0 THEN
RETURN ERROR.
/* end connect.p */