Author: spadkins
Date: Tue Jan 3 10:14:55 2012
New Revision: 15067
Modified:
p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm
Log:
support arbitrary DBI connection attributes to be set. (Useful for Oracle DRCP,
etc.) (e.g. {repname}.dbiattr = xyz,foo=5)
Modified: p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm
==============================================================================
--- p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm (original)
+++ p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm Tue Jan 3 10:14:55 2012
@@ -177,10 +177,25 @@
return 1 if (defined $self->{dbh});
+ my $name = $self->{name};
+ my $context = $self->{context};
+ my $options = $context->{options};
+
while ((!$self->{dbh} || !$self->{dbh}->ping())) {
my $dsn = $self->_dsn();
my $attr = $self->_attr();
+ if (exists $options->{"$name.dbiattr"}) {
+ foreach my $var (split(/,/, $options->{"$name.dbiattr"})) {
+ if ($var =~ /^([^=]+)=(.*)$/) {
+ $attr->{$1} = $2;
+ }
+ else {
+ $attr->{$var} = 1;
+ }
+ }
+ }
+
eval {
my $dbh = DBI->connect($dsn, $self->{dbuser}, $self->{dbpass},
$attr);
$self->{dbh} = $dbh;
@@ -194,6 +209,7 @@
}
}
};
+
if (my $e = $@) {
if ($self->is_retryable_connection_error($e)) {
$self->{context}->log({level=>1},"DBI Exception (retrying) in
_connect(): $e");