As part of a cloning exercise I need to be able to connect to a database on a remote server.(This is to extract the trace file so that we can edit it and automate the whole cloning process using a single Perl script) The only problem I'm having with this is the remote connection. I've edited the Oracle TNSNAMES.ora file locally and can connect to the remote box using SQLPLUS manually. When I try and use DBI within a Perl script I get the dreaded -
Can't connect to ihr-live :: ORA-12154: TNS:could not resolve
+service name (DBD ERROR: OCIServerAttach)
The TNSNAMES entry for the remote box looks like -
ihr-live =
(DESCRIPTION =
(ADDRESS = (PROTOCOL= TCP)(Host= skirlie)(port= 1521))
(CONNECT_DATA = (SID = IHRLIVE))
)
The connection code that I'm using is -
$dbh = DBI->connect('dbi:Oracle:ihr-live@ihr-live',"$uname","$password
+", {
PrintError => 0,
RaiseError => 0
}
The Oracle database is called ihr-live and I presume that the hostname is taken from the ihr-live alias in the TNSNAMES.ora file. As you can see from this file the remote server is called skirlie and the port being used is the default 1521. I hope I've made a simple mistake can someone point me in the right direction please?
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.