Could Not Resolve The Connect Identifier Specified Dbd Error Ociserverattach
Contents |
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. So I thought I would perl dbi connect oracle service name share a solution that helped me. I apologize if this has publised
Perl Dbi Oracle Connect Example
before as I did not find this here. I am really a MySQL user for many years. perl oracle connection Recently I had to deal with Oracle which I had not touched in 9+ years. So I needed a Quick Strategy to Connect to Oracle DB from Perl script. failed to connect to database instance: ora-12541: tns:no listener (dbd error: ociserverattach). 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: Couldn't connect to database db_name: ORA-12154: TNS:could
Dbd Oracle
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 $dbh = DBI->connect("dbi:Oracle:host=$host;sid=$sid;port=1521",$use +r,$passwd); [download] This is working wihere 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 Us Learn more about Stack Overflow the company Business Learn more about hiring perl dbi example developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask oracle sid 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
Ora-12154: Tns:could Not Resolve The Connect Identifier Specified
them; it only takes a minute: Sign up Regarding perl dbd oracle up vote 1 down vote favorite I have two queries When i run the below perl script i am getting the below error Unable to connect: ORA-12154: http://www.perlmonks.org/?node_id=809180 TNS:could not resolve the connect identifier specified (DBD ERROR: OCIServerAttach) I can't modify the tnsnames.ora as i dont have access. I know tnsnames.ora doesn't have a entry for testdb database. Is there a workaround. Thought i am accessing the database in the remote solaris machine with the IP Address so no need of a entry in the local solaris machine tnsnames.ora. $platform = "Oracle"; $database = "testdb"; $host = "testdb.dev.test.com.au"; $port = "2000"; $user = "scott"; $pw = "tiger"; http://stackoverflow.com/questions/14208937/regarding-perl-dbd-oracle $dsn = "dbi:$platform:$database:$host:3306"; print "$dsn" . "\n"; # PERL DBI CONNECT (RENAMED HANDLE) my $dbstore = DBI->connect($dsn, $user, $pw) or die "Unable to connect: $DBI::errstr\n"; 2 My understanding about DBD module is even oracle is not installed in the local machine DBD module should work. But i noticed while installation it uses oracle client libraries. So if i install a DBD::Sybase do i need to have a installation of sysbase in local machine. Since I am accessing remote server database thought why local installation of oracle/sybase libraries are required? perl share|improve this question edited Jan 8 '13 at 5:54 Chankey Pathak 10.5k73781 asked Jan 8 '13 at 5:48 Arav 97194082 can any one help me out for the second query? –Arav Jan 9 '13 at 3:09 Please check my comment in my answer for your second question. –slayedbylucifer Jan 9 '13 at 7:05 add a comment| 1 Answer 1 active oldest votes up vote 2 down vote accepted your dsn syntax is wrong. try to make it look like below: $dsn = "dbi:$platform:host=$host;sid=$sid;port=$port"; Above syntax has worked for me in numerous cases where I had used DBD::Oracle. share|improve this answer answered Jan 8 '13 at 7:00 slayedbylucifer 11.3k114485 Thanks a lot. It works now. could you pls have a look at my second question about the installation of DBD Module. –Arav Jan 8 '13 at 22:48
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 https://things2notefor.wordpress.com/tag/dbd-error-ociserverattach/ 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 perl dbi 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 could not resolve 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 client should have a write privilege on that directory, in this case, its /tmp. After several trace files, it got more confusing and misleading as the trace file indicates that it cannot find the TNS "path". So I came to think that the problem might related to a corrupted OCI driver. Thus we decided to reinstall the oracle client. We tested the perl script after the oracle client was reinstalled and we're back to square one because we have the core dump again. So I recreated the sqlnet.ora file and the core dump went away. But, we are now back to the ora-12154 error! THE FIX: Upon googling pages and pages of fo