Re: DB connection error handling

Michael Peppler <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase
Message-ID <[email protected]>
On Fri, 2004-10-15 at 13:02, [email protected] wrote:
> > Please can you help me handling the error in DB connection to Sybase
> 
> > Server and DB from perl code myself?

> > I am using Sybperl. and all the libraries exist. I am saying this 
> 
> > because we make DB connection in numerous instances; But we have a 
> 
> > specific requirement to put XYZ logic incase DB connection is not 
> 
> > made. 

Which version of sybperl do you have?

I just tried the following:

#!/usr/bin/perl -w

use strict;

use Sybase::DBlib;

my $db = new Sybase::DBlib 'sa', 'foo', 'localhost';
if(!$db) {
    print "connect failed!\n";
} else {
    print "connect worked\n";
}

__END__

which worked fine:

[mpeppler@localhost DBD-Sybase]$ perl ~/tmp/fail_con.pl
Msg 4002, Level 14, State 1
Server 'localhost',
        Login failed.
DB-Library error:
        Login incorrect.
connect failed!

Michael
-- 
Michael Peppler                              Data Migrations, Inc.
[email protected]                       http://www.peppler.org/
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short or 
long term contract positions - http://www.peppler.org/resume.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.