[Zope] Checking the state of a database connection

Andreas andreas@aHIT.de
Fri, 28 Jan 2000 09:16:00 -0700


> >Hannu Krosing writes
> >I have modified UserDB to just do close/open on the connection if the
> >query fails.
... and if the SQL server still is down ... ;-)
 
> Unfortunately, if I lose my ODBC connection, more often than not I have
> to shut Zope down, and restart it to reconnect the ODBC adapter.
> Otherwise it complains of an invalid log on string.

This solution works fine (only tested with Postgres) and you do not need
to 
restart Zope. 
Anyway it's only a work around because IMHO Database.connected() should
not
simply return the date of last successful connect call.

<!--#try-->
  <!--#call "Database.connect(Database.connection_string)"-->
  <!--#if "Database.connected()"-->
    Letīs do some query :-)
  <!--#else-->
    Database connection object not connected :-(
  <!--#/if-->
<!--#except BadRequest-->
  Possibly SQL server down :-( <BR>
  <!--#var error_type-->
  <!--#var error_value-->
<!--#/try-->
_________________________________________________________
Andreas Heckel                            andreas@aHIT.de