RE: Connecting to more than one oracle database



Malka Cymbalista wrote:
I am running Apache 2.0.55 with mod_perl 2.0.1 and Perl 5.8.1 on a Sun
Solaris machine. I am using DBI/DBD to connect to an Oracle database.
I am running DBI 1.39 and DBD-Oracle 1.16.

In order to connect to an oracle database on a different machine I
have a tnsnames.ora file with the appropriate definition. I also have
a file startup.pl with the following information:
$ENV{ORACLE_HOME} = '/usr/local/ora9i/9.2.0';
$ENV{ORACLE_SID} = 'asdb';
$ENV{TWO_TASK} = 'asdb';
$ENV{TNS_ADMIN} = '/usr/local/ora9i/9.2.0/network/admin/DEV_wiccdb';
In httpd.conf I have the line
PerlRequire "/www/httpd/conf/startup.pl"

I am currently connecting to an oracle database on a different machine
and everything is working fine. I would now like to connect to
another oracle database on another machine. My problem is how to
define my environment variables. ORACLE_HOME and TNS_ADMIN do not
seem to be a problem since I assume they can be the same. However,
how do I define ORACLE_SID and TWO_TASK so that they allow connecting
to 2 different databases on 2 different machines?

TWO_TASK and ORACLE_SID are defaults, and are not necessary if you can
specify the database name when you connect. Since you're using TNS, you
can just reference the TNS names in your connect string, e.g.:

my ($db,$user,$pass);

($db,$user,$pass) = ('asdb','user','pass');
my $dbh_1 = DBI->connect("dbi:Oracle:$db",$user,$pass)
|| die "can't connect: $DBI::errstr";

($db,$user,$pass) = ('other_db','user','pass');
my $dbh_2 = DBI->connect("dbi:Oracle:$db",$user,$pass)
|| die "can't connect: $DBI::errstr";

Regards,
Philip
.



Relevant Pages

  • RE: Connecting to more than one oracle database
    ... In order to connect to an oracle database on a different machine ... I am currently connecting to an oracle database on a different ... CONFIDENTIALITY NOTICE This e-mail and any files or attachments may contain confidential and privileged information. ...
    (perl.dbi.users)
  • Re: oracle jdbc abd OpenOffice 2.0
    ... in the course of finding out how to connect an Oracle database ... Error while connecting to data source ... error code 17002 ... Server URL: localhost ...
    (comp.databases.oracle.server)
  • Intermittend ORA-12519, TNS:no appropriate service handler found
    ... connecting via JDBC we get intermittend ORA-12519 (reflected as TNS-12519 ... wise and memory wise). ... job scheduling to check whether there might be a job that eats up ... Oracle Database 10g Enterprise Edition ...
    (comp.databases.oracle.server)
  • Re: OCIServerAttach returns ORA-12514
    ... I have a small C application which connects to an Oracle database using ... Please find a code snippet below. ... the code works when connecting to certain database instances but not to ... But you say that "other applications are able to connect"? ...
    (comp.databases.oracle.server)
  • Connect a Web Part to an Oracle db
    ... Can someone provide sample C# code for connecting a web part to an ... Oracle database? ... A simple example would suffice eg. selecting a couple of columns from a ...
    (microsoft.public.sharepoint.portalserver.development)