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

How can we connect to a oracle database in windows box from a linux box which has oracle clent installed ? How can we do this using perl DBI ? Is this possible using normal connection string in Perl DBI ? eg: $dbh = DBI->connect('dbi:Oracle:test','username','passwd') or die "Cannot connect to database $dbh->errstr"; Please help me.

Thanks in advance

  • Comment on How can we connect to a oracle database in windows box from a linux box

Replies are listed 'Best First'.
Re: How can we connect to a oracle database in windows box from a linux box
by marto (Cardinal) on Jul 10, 2012 at 13:48 UTC

    Before getting Perl involved you'll need to ensure you can connect from your Linux system to Oracle running elsewhere. Ensure that tnsnames.ora is configured correctly then try to connect using Oracle tools such as sqlplus/tnsping. Consult the Oracle documentation for help on this. Once this works you should be able to use Perl (DBI with DBD::Oracle) to connect to Oracle.

    Update: Come to think of it, the oracle client tools provide a Java GUI based Wizard app for configuring and testing connections. Perhaps this is useful to you.

Re: How can we connect to a oracle database in windows box from a linux box
by chacham (Prior) on Jul 10, 2012 at 13:59 UTC
    Please explain once more:
    1. Where is the database?
    2. Where is the client?
    3. Where is the code being run from?

    It might help to get it running on the same box before making it work remotely. Here is an example i have from a linux box connecting to XE on the same box.

    DBI->connect('dbi:Oracle:XE', 'scott', 'tiger', {RaiseError => 1, Auto +Commit => 0}) or die "Database connection not made: $DBI::errstr";}

      They're specifically asking how to connect from a Linux machine to Oracle running on a Windows machine. Setting up an Oracle database on the Linux server to prove that connecting works locally seems like an unnecessary step, since this isn't their goal.

        Thanx. When i read it this morning, i was a bit confused, and wanted a little more clarity. But i see it now. And, there are more details posted below. Thanx!

      Hi

      The database is vantive which runs on windows box atl-vanapp01 to atl-vanapp10 depending upon the availability of the server. Client is in local linux box. The query is run on windows box and the code to fetch the data is run from local unix box.

      Thanks

        OK, standard debugging.

        Can you tnsping the db from the linux box? IIRC, the Oracle client will handle it from there, so the normal connection string ought to work.

        I mean local linux box