Q: How to handle connection failures

Intercept the DATABASE_ERROR exception as shown below.

Example A-2. Intercpetion connection errors


      begin

         EXEC SQL CONNECT $DBUSER 
                  IDENTIFIED BY $DBPASSWD
                  BY DB01 
                  TO $DBSOURCE ;    -- Hallo Test
         ...............
      exception
         when GNU.DB.SQLCLI.DATABASE_ERROR =>
            Put_Line("Connection Error");
            .....................
      when Others =>
         raise;
      

In addition GNADE esql provide the ON clause in the CONNECT statement which allows to intercept communication and authorization errors.