Subject Re: [IBO] How to see if server is installed and running?
Author Helen Borrie
At 11:32 AM 15/04/2005 +0000, you wrote:

>--- In, Helen Borrie <helebor@t...> wrote:
> > Steve,
> >
> > At 07:23 PM 14/04/2005 +0000, you wrote:
> >
> >
> > >Hi All,
> > >
> > >How can I determine from within my application if Firebird is
> > >installed and running?
> >
> > The question as asked is a needle in a haystack. Depending on the
> > conditions you need to test, this could be a) simple, b) complicated c)
> > unreliable or d) impossible.
> >
> > Can you be more explicit about what, where and why you want to test
> > this? If necessary make a truth table of the conditions your
> > has to cover and what you want to do about it, including:
> >
> > Firebird? (as opposed to InterBase)
> > Firebird version?
> > Installed and running?
> > - locally?
> > -remotely?
> > Installed but not running?
> > - locally?
> > -remotely?
> > Not installed locally?
> > Not installed at all?
>Hi Helen,
>I have a client with a Firebird application running at about 60 out of
>700 sites. I've written a suite of applications for him and some need
>to know if the Firebird application is being used on the local machine
>before running certain processes.
>Only Firebird v1.5x is used.
>Firebird is always installed locally
>The Firebird service should be running if installed.
>I'd like to know if Firebird is running to avoid throwing exceptions
>by trying to connect to a server that doesn't exist or isn't running.

Then it's really easy. Connect to the database. If connection fails for
any reason at all you will get an exception. Just catch the exception,
handle it by sending an appropriate message to the user and abort. (That's
what exceptions are for!! you don't avoid them - you get the information
you want from them and you handle them.)

You might wish to write a handler that deals with a range of gdscode
connection-time exception codes in their exact contexts, e.g. bad
username/password means the server is installed and running but the login
failed at authentication. You can download all the gdscodes and their
meanings from the Contributed Downloads page.