perlfellas has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am trying to connect with one oracle database thru perl script. But it is giving timed out error. But to my surprise, I am able to connect with the same database thru ”sqlplus” command in the same UNIX server where I have the perl script. Could anyone please tell me what could be the problem? Below is the sample script which I am using.
use strict; use DBI; my $DBI_DSN = "dbi:Oracle:DB_NAME"; my $DBI_USER = "user"; my $DBI_PASS = "password"; $dbh = DBI->connect($DBI_DSN, $DBI_USER, $DBI_PASS, {AutoCommit => 0, RaiseError => 0, LongReadLen => 2000000, LongTruncOk => 0}) ;
Thanks

CODE tags added by Arunbear

Replies are listed 'Best First'.
Re: Oracle Timed Out error
by wazoox (Prior) on May 06, 2005 at 11:08 UTC
    Please provide an example of the code that fails. Better, write a short test script to see if you can connect. Here's one :
    #!/usr/bin/perl -w use strict; use DBI; use DBD::Oracle qw(:ora_types); use Data::Dumper; my $host="10.1.0.1"; my $sid="ora9i"; my $user="test"; my $passwd="test"; print 'DBI '.$DBI::VERSION."\nDBD ".$DBD::Oracle::VERSION."\n"; my $dbh = DBI->connect("dbi:Oracle:host=$host;sid=$sid", $user, $passw +d) or die "can't connect : $!"; print "connected as $user to $host \n" if $dbh ;
Re: Oracle Timed Out error
by VSarkiss (Monsignor) on May 06, 2005 at 14:08 UTC

    The situation, as you've described it, is impossible. Both sqlplus and DBD::Oracle use the same interface to Oracle. Start looking for some differences in how you execute the commands.

    • Do you have ORACLE_HOME defined the same in both circumstances?
    • Are you sure you're using the same database name, user, password, etc., in both cases?
    • Is your perl script running from the command line or a CGI? Is it the same user executing both scripts?

    If none of these give you a clue, try using a third tool (tnsping, toad, tora, etc.) to get another data point.