Reputation: 635
I have an oracle db 12c running in a container. What i am trying do is check connection to a oracle db using a perl script running in another container using the following code
#!/usr/bin/perl
use DBI;
$\="\n";
print "Connecting to DB..";
my $dbh = DBI->connect('dbi:Oracle:ORCLCDB', 'books_admin', 'MyPassword') or
die "Cannot connect to DB => " . DBI->errstr;
where books_admin is my username and MyPassword is my password ORCLCDB is my database name But when i ran this script im getting the following error
"ORA-12154: TNS:could not resolve the connect identifier specifiedenter"
This is my tnsname.ora file place in perl container.
ORAC =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORCLCDB)
)
)
LISTENER_ORAC =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1522))
Upvotes: 2
Views: 1764
Reputation: 4150
Ref. the doc: "If the database is defined in a TNSNAMES.ORA
file, you can use the service name given in the file."
For example: $dbh = DBI->connect('dbi:Oracle:host=foobar;sid=DB;port=1521', 'scott/tiger', '');
The service identifier is ORAC
referring to your tnsnames.ora
entry.
Upvotes: 2