Error Ora-12154 Dbd Error Ociserverattach
Contents |
CoolUsesForPerl PerlNews Q&A Tutorials Poetry RecentThreads NewestNodes Donate What'sNew on Nov 24, 2009 at 19:34UTC ( #809180=perlmeditation: print w/replies, xml ) Need Help?? I don't usually visit here. I should change that fact. perl dbi oracle service name So I thought I would share a solution that helped me.
Perl Dbi Connect Oracle Example
I apologize if this has publised before as I did not find this here. I am really a perl oracle connection MySQL user for many years. Recently I had to deal with Oracle which I had not touched in 9+ years. So I needed a Quick Strategy to Connect dbd::oracle to Oracle DB from Perl script. I hope this helps someone else... "My Thanks to Michael's Blog for this ... After successful installation of DBD::Oracle it’s time to use it. The connection string is the same as for he rest DB: my $dbi= DBI->connect("dbi:Oracle:$db_name:$db_host:$db_port", $db_user, $db_pa +ss); [download] As result of running code above I got following error:
Perl Dbi Example
Couldn't connect to database db_name: ORA-12154: TNS:could not resolve the connect identifier specified (DBD ERROR: OCIServerAttach) After googling I found that the problem was that. I tried to connect to the remove database but the driver couldn’t do that without special file – tnsnames.ora. It should be placed to the $ORACLE_HOME/network/admin and contain something like that: db_name = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = db_host)(PORT = db_port)) ) (CONNECT_DATA = (SERVICE_NAME = db_name) ) ) [download] And the connection string should be changed to use service name from the tnsnames.ora instead of host: my $dbi = DBI->connect("dbi:Oracle:$service_name", $db_user, $db_pass); Finally we should export variable ORACLE_SID into our environment. Add this command into .bashrc export ORACLE_SID="orcl" or set it using Perl variable $ENV: $ENV{ORACLE_SID} = 'orcl'; Comment on RFC: Oracle Perl ConnectionSelect or Download Code
Replies are listed 'Best First'. Re: RFC: Oracle Perl Connection by keszler (Priest) on Nov 24, 2009 at 19:44UTC To avoid the need for a tnsnames.ora entry, I've been using: my $here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About oracle sid Us Learn more about Stack Overflow the company Business Learn more about hiring ora-12154: tns:could not resolve the connect identifier specified developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Error ORA-12154 on DBI->connect to Oracle http://www.perlmonks.org/?node_id=809180 database with Oracle Instant Client in Solaris 10 up vote 0 down vote favorite I've been pulling my hair out over this problem for two days now: I'm trying to get a perl script to interface with an Oracle database. I have a new server I'd like to deploy my application on. This script previously worked. Here's what I've done so far: Placed my tnsnames.ora file in http://stackoverflow.com/questions/16114916/error-ora-12154-on-dbi-connect-to-oracle-database-with-oracle-instant-client-in instantclient/network/admin: ls -la network/admin/ total 8 drwxrwxrwx 2 m staff 512 Apr 19 09:54 . drwxrwxrwx 3 m staff 512 Mar 28 15:56 .. -rwxrwxrwx 1 m staff 777 Apr 19 09:54 tnsnames.ora My Perl script looks like this: 12 use CGI; 13 use DBI; 14 use Data::Dumper; 15 use strict; 16 28 $ENV{ORACLE_HOME} = "/xxx/instantclient/"; 29 32 $ENV{'LD_LIBRARY_PATH'} = "xxx/instantclient/lib"; 33 35 use DBD::Oracle; 36 37 print "DBI::VERSION: $DBI::VERSION\n"; 38 print "$DBD::Oracle::VERSION\n"; 66 my $dbh = DBI->connect("dbi:Oracle:host=computer;port=1521;sid=mydatabase", "user", "pass"); 67 my $sth = $dbh->prepare("SELECT sysdate FROM dual"); 68 my $rv = $sth->execute; 69 DBI::dump_results($sth) if $rv; 70 $dbh->disconnect; 71 72 print "$database $dbUser $dbPassword \n"; 73 74 my $dbh = DBI->connect( $database, $dbUser, $dbPassword ) or die("PROBLEM WITH LINE:\n$! , stopped"); This script produces this output: DBI::VERSION: 1.609 DBD::Oracle version: 1.24 '19-APR-13' 1 rows dbi:Oracle:mydatabase user pass DBI connect('mydatabase','user',...) failed: ORA-12154: TNS:could not resolve the connect identifier specified (DBD ERROR: OCIServerAttach) at ./code.pl line 74 My tnsnames.ora file contains the following entry: mydatabase = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = computer )(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = service.computer.com) ) ) This tnsnames.ora file has been copied from a working machine, so I'm co
this POD Website CPAN RT New 4 Open 14 Stalled 1 View/Report Bugs Source LatestRelease:DBD-Oracle-1.75_2 NAME VERSION CONNECTING TO ORACLE Oracle utilities Connecting using a bequeather USING http://search.cpan.org/~pythian/DBD-Oracle-1.52/lib/DBD/Oracle/Troubleshooting.pod THE LONG TYPES Can't find libclntsh.so Miscellaneous Crash with an open https://things2notefor.wordpress.com/tag/dbd-error-ociserverattach/ connection and Module::Runtime in mod_perl2 bin_param_inout swapping return values AUTHORS COPYRIGHT AND LICENSE NAME DBD::Oracle::Troubleshooting - Tips and Hints to Troubleshoot DBD::Oracle VERSION version 1.52 CONNECTING TO ORACLE If you are reading this it is assumed that you have successfully installed DBD::Oracle and you are perl dbi having some problems connecting to Oracle. First off you will have to tell DBD::Oracle where the binaries reside for the Oracle client it was compiled against. This is the case when you encounter a DBI connect('','system',...) failed: ERROR OCIEnvNlsCreate. error in Linux or in Windows when you get OCI.DLL not found The solution to this problem in error ora-12154 dbd the case of Linux is to ensure your 'ORACLE_HOME' (or LD_LIBRARY_PATH for InstantClient) environment variable points to the correct directory. export ORACLE_HOME=/app/oracle/product/xx.x.x For Windows the solution is to add this value to you PATH PATH=c:\app\oracle\product\xx.x.x;%PATH% If you get past this stage and get a ORA-12154: TNS:could not resolve the connect identifier specified error then the most likely cause is DBD::ORACLE cannot find your .ORA (TNSNAMES.ORA, LISTENER.ORA, SQLNET.ORA) files. This can be solved by setting the TNS_ADMIN environment variable to the directory where these files can be found. If you get to this stage and you have either one of the following errors; ORA-12560: TNS:protocol adapter error ORA-12162: TNS:net service name is incorrectly specified usually means that DBD::Oracle can find the listener but the it cannot connect to the DB because the listener cannot find the DB you asked for. Oracle utilities If you are still having problems connecting then the Oracle adapters utility may offer some help. Run these two commands: $ORACLE_HOME/bin/adapters $ORACLE_HOME/bin/adapters $ORACLE_HOME/bin/sqlplus and check the o
PROBLEM: Recently, we've encountered a problem in one of our test systems. Whenever a user uses perl to connect to the database, the script crashes and creates a core dump. However, when using SQL*Plus or tnsping, no error is encountered or core dump created. Our environment is running on Solaris 10 (x86-64) and Oracle 10g. TROUBLESHOOTING: Â At first we looked at the environment settings and found that everything is set accordingly. Next thing I did is to run a truss command and as expected it gave me the file (missing sqlnet.ora) it is looking for before it crashes. So I created the sqlnet.ora under $ORACLE_HOME/network/admin directory, ran the perl script and voila (!), no more core dump. However, I encountered another problem. The script does not connect to the database and the error is a misleading error (ORA-12154) as tnsping works, SQL*Plus connection works with no issue! lab-ora:/tmp/conn.pl DBI connect(‘lab_ora','devusr',…) failed: ORA-12154: TNS:could not resolve the connect identifier specified (DBD ERROR: OCIServerAttach) at conn.pl line 4 Database connection not made: ORA-12154: TNS:could not resolve the connect identifier specified (DBD ERROR: OCIServerAttach) at conn.pl line 4. So this time, I enabled a sqlnet.ora trace by specifying the following parameters in sqlnet.ora: Â TRACE_LEVEL_CLIENT = SUPPORT TRACE_DIRECTORY_CLIENT = /tmp TRACE_LEVEL_CLIENT parameter values are OFF, USER, ADMIN, SUPPORT. By default, or if not specified, it's value is OFF. Set the value depending on how much detailed you want your trace file to have. (For details and description please refer to Metalink Note 216912.1 ). I've set ours to SUPPORT hoping I would get the information I need to fix this misleading error. TRACE_DIRECTORY_CLIENT can be set to any valid directory in your system and the user that own's your oracle cli