Bellow is the Apache Startup script, The connect module I use, and the connection string I use in my perl scripts.
Any suggestion on why Apache::DBI won't reconnect ?
David Hofmann
--- My Apache Startup Script ---
# make sure we are in a sane environment. $ENV{MOD_PERL} or die "not running under mod_perl!";
use strict;
use Carp ();
use Apache::DBI ();
DBI->install_driver("Pg");
# $Apache::DBI::DEBUG = 0;
Apache::DBI->connect_on_init("DBI:Pg:dbname=SERVERNAME;host=HOSTNAME;port=PORT;","USERNAME", "PASSWORD")
or die "Cannot connect to database: $DBI::errstr";
1; #return true value
-- End Starup --
-- My Connect Module --
package MY::DBConnect;
use strict; use Carp; if ($ENV{MOD_PERL}) { use Apache::DBI; } use DBI (); use MY::Error;
sub connect { if (defined $MY::DBConnect::conn) { eval { $MY::DBConnect::conn->ping; }; if (!$@) { return $MY::DBConnect::conn; } }
### Perform the connection using the driver
$MY::DBConnect::conn = DBI->connect( "dbi:Pg:dbname=SEVERNAME;host=HOSTNAME-;port=PORT","USERNAME", "PASSWORD")
or &error('0','EN','CONNECT_SQL','CONNECT_SQL','The Support site is currently experiencing technical difficulties. Please try again later. We apologize for any inconvenience.',1 );
return $MY::DBConnect::conn;
}
1;
-- End Connect Module --
-- Connection sting in scripts --
use DBI (); use MY::DBConnect;
### Perform the connection using the driver my $dbh ||= &MY::DBConnect::connect;
-- End Scripts stuff --
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
-- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html