This is showing in my apache error.log:
[Wed Oct 12 22:13:18 2005] [notice] Apache/1.3.33 (Debian GNU/Linux) m
+od_ssl/2.8.24 OpenSSL/0.9.7g mod_perl/1.29 configured -- resuming nor
mal operations
[Wed Oct 12 22:13:18 2005] [notice] Accept mutex: sysvsem (Default: sy
+svsem)
[Wed Oct 12 22:13:18 2005] [error] Can't connect to data source Pg:dbn
+ame='rodneyd', no database driver specified and DBI_DSN env var not s
et at /usr/local/share/perl/5.8.7/Apache/DBI.pm line 146\n
[Wed Oct 12 22:13:18 2005] [error] Can't connect to data source Pg:dbn
+ame='rodneyd', no database driver specified and DBI_DSN env var not s
et at /usr/local/share/perl/5.8.7/Apache/DBI.pm line 146\n
[Wed Oct 12 22:13:18 2005] [error] Can't connect to data source Pg:dbn
+ame='rodneyd', no database driver specified and DBI_DSN env var not s
et at /usr/local/share/perl/5.8.7/Apache/DBI.pm line 146\n
[Wed Oct 12 22:13:18 2005] [error] Can't connect to data source Pg:dbn
+ame='rodneyd', no database driver specified and DBI_DSN env var not s
+et at /usr/local/share/perl/5.8.7/Apache/DBI.pm line 146\n
I have this as my apache httpd.conf perl stanza:
PerlModule Apache::DBI
PerlModule Apache::Session::Postgres
PerlModule Apache::Cookie
PerlRequire /etc/apache-perl/db.pl
db.pl:
my $dsn = 'rodneyd';
my $usn = 'postgres';
Apache::DBI->connect_on_init(qq{dbi:Pg:dbname=$db}, $usn, '' ) || die
+"bleh";
Apache::DBI->setPingTimeOut($dsn, 30 );
1;
Any ideas why I'm getting this error? Or what to do about it, I have tried setting the env variable in apache and in $ENV{DBI_DSN} no joy.
update #1.
Fixed typo, The error from the error.log is comming from my auctual web page which connects with the following :
$dbh = DBI->connect("dbi:Pg:dbname=rodneyd",q/postgres/,"",{AutoCommit
+ =>0, RaiseError=>1, PrintError=>0}) || die "Could not Connec
t to DB".$dbi::errstr;
I assume that works, because the database ran fine with that exact string before I started to use Apache::DBI, and it pulls from the database fine.
UPDATE!!! LEARN SOMETHING FROM THIS
Apache aparently doesn't update the files in the PerlRequire pragma from restart, they must be cached somewhere, I shut down computer and everything worked. Start/stop fails to update this as well. Here is the kicker, apache-perlctl has a 'graceful' arguement that restarts it with a different signal. That forced apache to update my db.pl file. Joy at last. Things work.
Update
It seems as if it might be the duration in between the start/stop.
UPDATE!!! LEARN MORE FROM THIS
I believe this to be a bug in DBI::Apache too, because of the crappy error message. It would apear as if the problem was in the dsn. To get the error again all one must do is seperate the dbi/driver fields with two colons rather than one.
IE. this works
Apche::DBI->connect_on_init(qq{dbi:Pg:dbname=$db}, $usn, '' ) || die;
IE. this doesn't. (And, yeilds the aforementioned error.).
Apche::DBI->connect_on_init(qq{dbi::Pg:dbname=$db}, $usn, '' ) || die;
While I understand why this works, or fails to work, this error message is sort of deceptive, and this could have been resovled with a simple regex in DBI::dsn_parse. I had probably went back and forth a few times on the dsn to hash this out. The first error could have been the spelling error jbrugger pointed out, and each time afterward it could have been the failure to update, without waiting inbetween the start/stop.
Evan Carroll
www.EvanCarroll.com
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.