My dbi_test.pl script works fine when doing local on terminal. When getting this on my apache I'm getting: dbi_test.pl: DBI connect('_DBNAME_','_DBUSER_',...) failed: ORA-12154: TNS:could not resolve the connect identifier specROR: OCIServerAttach) at /srv/www/cgi-bin/dbi_test.pl line 14.

My dbi_test.pl script is:

#!/usr/bin/perl -w use strict; use DBI; # Deklaration der lokalen Variablen my ($dbh); my $db_name = "_DBNAME_"; my $db_user = "_DBUSER_"; my $db_pwd = "_DBUSER_PWD_"; $dbh = DBI->connect("dbi:Oracle:$db_name", $db_user, $db_pwd, {RaiseEr +ror=>0, PrintError=>0 , AutoCommit => 0}); if (!defined $dbh) { print "DB-Connect-Fehler: $!\n"; exit; } my $hStatement = $dbh->prepare("SELECT count(*) FROM tbl"); $hStatement->execute; my @count = $hStatement->fetchrow_array(); print "Content-Type: text/html\n\n"; foreach (@count){ print "$count[0]\n"; } $hStatement->finish; $dbh->disconnect;

Already researched and tried to get where the problem is, but in case that i can use sqlplus without any problems it seems like the problem has to be with apache ... i did:

 perl -e 'use CGI ":all";print header;print "<pre>\n";map { print "$_ $ENV{$_}\n" } sort keys %ENV;print "</pre>\n";'

to get my Apache-Environment-Variables and imo everything should be okay. Oracle-Base, Oracle-Home, Tns-Admin, Ld-Library-Path everything is set ...

I don't have a clue how to go on ...


In reply to DBI::Oracle - fails on apache ( ORA-12154) - but works fine local by Yaerox

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.