Hi 

I tried the following example to try to connect to my testing database but
failed. Please help. Thanks

x

/usr/local/db2/users/db2su/proj/perlsrc> test2.pl
databases: 2
Failed to connect to sample:  : No message of desired type

#!/usr/bin/perl

#use lib '/usr/local/db2/users/db2su/perl/lib';

use DBI;
use DBD::DB2::Constants;
use DBD::DB2;

$username = "eastjdbc";
$password = "kaw452sky";

$DBI::dbi_debug=9;
$dbstr =  DBI->data_sources('DB2');
print "databases: $dbstr \n";

$dbh = DBI->connect("DBI:DB2:sample", "", "", { LongReadLen => 100 } );
unless (! defined($dbh)) {
        print "Failed to connect to sample: $DBI::errstr : $! \n";
        exit (-1);
}

$query = "SELECT * from employee";
$sth = $dbh->prepare($query);
$sth->execute();

while( @row = $sth->fetchrow ) {
        print "@rows \n";
}

$dbh->disconnect();

exit(0);

Reply via email to