laminee has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to replicate the sqlplus '/as sysdba' connection using DBI and DBD::Oracle by following the guidelines from http://search.cpan.org/~pythian/DBD-Oracle-1.23/Oracle.pm#Connect_Attributes.
My tnsnames.ora is like this:
and I have no problem connecting with the usual sqlplus '/as sysdba'.#Generated tnsnames.ora by gen_tnsnames.sh script #Localnode service connectivity ABCD12.COMPANYDOMAIN.COM = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = testserver24.companydomain.co +m )(PORT = 30710)) ) (CONNECT_DATA = (INSTANCE_NAME = ABCD12) (SERVICE_NAME = ABCD12.COMPANYDOMAIN.COM) ) )
I am doing the following in my script:
and getting the error:use DBI; use DBD::Oracle qw(:ora_session_modes); my $dsn = "dbi:Oracle:"; #$ENV{ORACLE_SID} = "ABCD12"; $ENV{ORACLE_SID} = "ABCD12.COMPANYDOMAIN.COM"; delete $ENV{TWO_TASK}; my $dbh = DBI->connect($dsn, "", "", { ora_session_mode => ORA_SYSDBA +});
DBI connect('','',...) failed: ORA-12545: Connect failed because targe +t host or object does not exist (DBD ERROR: OCIServerAttach)
Specifying ORACLE_SID with/without the domain name doesn't change the error message. I have checked that $TNS_ADMIN is defined and the host name is present in /etc/hosts.
What am I doing wrong here?
Thanks, Ani
|
|---|