Consultor Eletrônico



Kbase P8487: How to find out if a database is running on the server side?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   03/04/2006
Status: Unverified

GOAL:

How to quickly find if a database is running on a remote server given the hostname, port number or service name?

GOAL:

How to find if a database is running in a client server environment.

FIX:

The following code uses the database host name and port number to check if the database running or not. The service name may be used in this code sample instead of the port number:
DEFINE VARIABLE hSocket AS HANDLE NO-UNDO.
DEFINE VARIABLE cService AS CHARACTER NO-UNDO.
DEFINE VARIABLE cHostName AS CHARACTER NO-UNDO.
DEFINE VARIABLE lResult AS LOGICAL NO-UNDO.
CREATE SOCKET hSocket.
ASSIGN
cService = "9999" /* This value could also be replaced by the service name */
cHostName = "HostName"
lResult = hSocket:CONNECT("-H " + cHostName + " -S " + cService) NO-ERROR.
IF hSocket:CONNECTED() THEN
MESSAGE "Database is running."
VIEW-AS ALERT-BOX INFO BUTTONS OK.
ELSE
MESSAGE "The Database is NOT running on this port"
VIEW-AS ALERT-BOX INFO BUTTONS OK.