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

Hi everyone,
I am trying to connect to Oracle RAC (Real Application Clusters) using the DBI module.
I found the following example:

$dbh=DBI->connect('dbi:db_driver:','db_user@db_host/db_name','db_pass')

I tried it and it works fine.
My question is : Is there a way to give a port which is different from the default port (1521)?
In the standard connection string there is such option:

$dbh = DBI->connect("dbi:db_driver:host=$db_host;sid=db_name;port=$db_port",db_user,db_pass)

Thanks

Replies are listed 'Best First'.
Re: DBI Connection with RAC
by dasgar (Priest) on Oct 11, 2010 at 14:42 UTC

    You might want to check out DBD::Oracle. Found the following example lines of code from its documentation where the port number is specified:

    $dbh = DBI->connect('dbi:Oracle:host=foobar;sid=ORCL port=1521', 'scot +t/tiger', '') $dbh = DBI->connect('dbi:Oracle:', q{scott/tiger@(DESCRIPTION=(ADDRESS +=(PROTOCOL=TCP)(HOST= foobar)(PORT=1521))(CONNECT_DATA=(SID=ORCL)))}, + "")
      I tried it but it doesn't work.
      Is there another way?

        Unfortunately I don't have Oracle and my experience with it is limited to my very limited exposure to it while taking a database class in college. However, I do have a few ideas.

        The first thing that I would test is to see if the Oracle client can connect from the same system that you're running your Perl code from. If that can't connect, you probably won't be able to connect via Perl or any other language. Also, that test will help verify that you have the Oracle driver installed on your OS.

        Second, make sure that you don't have a firewall blocking the desired port.

        Other than that, I'm not sure what other suggestions that I could offer.