In case it is of interest I have solved the problem like this.

package GSystem::Common::DBH;

use strict;
use warnings;
use Log::Log4perl qw(get_logger);
use DBI;

our $dbh = undef;

sub dbh {

my $log = get_logger('GSystem::Common::DBH');

my $dbusr = "user";
my $dbpwd = "pwd";
my $dsn = "GSystem";

$dbh = DBI->connect("DBI:ODBC:$dsn", $dbusr, $dbpwd, {RaiseError => 0, PrintError => 0}) || $log->logdie ("Could not connect to database")
 unless defined $dbh;

   return $dbh;
}

1;

So when I want a dbh I use

my $dbh = GSystem::Common::DBH::dbh;

and I (think) I either get a new or existing dbh.

I would be interested to know of any flaws in my logic...

Mark



#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################

Reply via email to