Michael Peppler
Sybase Consulting
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
Sybase on Linux FAQ
Sybperl FAQ
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Michael Peppler <mpeppler at peppler dot org>
Subject: dblib connection question..
Date: Mar 24 1999 2:22AM

Narasayya Immid writes:
 > Hi Everyone,
 >     I am using sybperl DBlib to connect to database, as
 > foreach $server (keys % SYNC_SERVER_LIST)
 > {
 > $dbh2 = Sybase::DBlib->dblogin("$user",$user_pwd,$server);
 >   if($dbh2 != null)
 > some action..
 > }
 > The connection is been called in a loop for three sybase servers. If for
 > some reason, one server is down, the above login call aborts the entire
 > program, by giving a 
 > message : DB-Library: Unable to connect: SQL Server is unavailable or
 > does not exist. 

The problem must be in your error/message handlers.

I tried this, both with the handlers and with nothing at
all, and it worked fine:


use Sybase::DBlib;

require '';

my @servers = qw(foo plum nunya kiruna);

foreach (@servers) {
    $dbh = new Sybase::DBlib 'webuser', 'webuser', $_;
    if($dbh) {
	print "Could connect to $_\n";
    print "Couldn't connect to $_... trying next\n";

kiruna (6:20PM):596 > perl ~/tmp/ 
Sybase error: Server name not found in interface file.
Couldn't connect to foo... trying next
Sybase error: Unable to connect: SQL Server is unavailable or does not exist.
Couldn't connect to plum... trying next
Could connect to nunya
kiruna (6:20PM):596 > 

Michael Peppler         -||-  Data Migrations Inc.    -||-
Int. Sybase User Group  -||-
Sybase on Linux mailing list: