Apache::DBI works transparently, so if one scripts works, and the other doesn't, then there must be differences in the way you connect in the two scripts. In other words a script that works without Apache::DBI must also work with Apache::DBI!

Try the following bit of code and see what you get...

#!/usr/bin/perl use CGI qw/:standard/; use DBI; use Data::Dumper; $Apache::DBI::DEBUG = 2; # Turn on Apache::DBI debugging print header, start_html('Testing Apache::DBI'), h1('Testing Apache::DBI'); my $dbh; eval { $dbh = DBI->connect( "DBI:mysql:database=test;host=localhost", undef +, undef, { RaiseError => 1 } ) ; }; if ($@) { print p('DBI Error: '.$@); } else { print p('Connect success'); print p("We are using Apache::DBI") if $dbh->isa('Apache::DBI::db'); print pre(Dumper($dbh)); } print end_html();

When I call that with Apache::DBI enabled, I get the following:

Testing Apache::DBI

Connect success

We are using Apache::DBI

$VAR1 = bless( {}, 'Apache::DBI::db' );

And in my error log I get:

13692 Apache::DBI need ping: yes
13692 Apache::DBI new connect to 'database=test;host=localhostAutoCommit=1PrintError=1RaiseError=1'

Cheers,

Cees

Update: Looks like this got solved while I was writing my test script. I guess I'll have to be quicker next time...


In reply to Re: Re: Re: accessing Apache::DBI 'cached connections' by cees
in thread accessing Apache::DBI 'cached connections' by geektron

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.