perl DBI连接oracle的问题

对于不同的ORACLE连接串,可能需要调整连接方式,都需要有ORACLE客户端:

1. dwapprac =

(DESCRIPTION=

(ADDRESS=(PROTOCOL=TCP)(HOST=10.125.60.25)(PORT=1521))

(ADDRESS=(PROTOCOL=TCP)(HOST=10.125.60.26)(PORT=1521))

(LOAD_BALANCE=yes)

(CONNECT_DATA=

(SERVER=DEDICATED)

(SERVICE_NAME=dwapprac)

(FAILOVER_MODE=

(TYPE=SELECT)

(METHOD=BASIC)

(RETRIES=180)

(DELAY=5)

)

)

   )
my $db_url="dbi:Oracle:$database_name";
                my $dbh = DBI->connect($db_url,$db_user,$db_password
                                ,{AutoCommit => 1
                                ,RaiseError => 0
                                ,PrintError => 0}
                               ) or printf STDERR "$DBI::err ($DBI::errstr)\n";
                unless ( defined($dbh) ) { return undef; }
                return ($db_type,$dbh);

2. dwapp =

(DESCRIPTION=

(LOAD_BALANCE=NO)

(ADDRESS_LIST=

(ADDRESS=(PROTOCOL=TCP)(HOST=10.125.70.54)(PORT=1522))

(ADDRESS=(PROTOCOL=TCP)(HOST=10.125.70.55)(PORT=1522))

)

(CONNECT_DATA=

(SERVICE_NAME=dwapp)

)

  )
my $db_url="dbi:Oracle:host=$host;sid=$database_name;port=$port";
                my $dbh = DBI->connect($db_url,$db_user,$db_password
                                ,{AutoCommit => 1
                                ,RaiseError => 0
                                ,PrintError => 0}
                               ) or printf STDERR "$DBI::err ($DBI::errstr)\n";
                unless ( defined($dbh) ) { return undef; }
                return ($db_type,$dbh);
 

相关推荐