Yaerox has asked for the wisdom of the Perl Monks concerning the following question:
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 ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI::Oracle - fails on apache ( ORA-12154) - but works fine local
by marto (Cardinal) on Apr 16, 2014 at 10:08 UTC | |
by Yaerox (Scribe) on Apr 16, 2014 at 10:26 UTC | |
by marto (Cardinal) on Apr 16, 2014 at 10:28 UTC | |
by Yaerox (Scribe) on Apr 16, 2014 at 11:19 UTC | |
|
Re: DBI::Oracle - fails on apache ( ORA-12154) - but works fine local
by Yaerox (Scribe) on Apr 16, 2014 at 12:22 UTC | |
by Yaerox (Scribe) on Apr 16, 2014 at 12:58 UTC |