- 论坛徽章:
- 0
|
#!/usr/bin/perl
use DBI;
$dsn = 'DBI:Sybase:server=sql1';
my $dbh = DBI->connect($dsn, "test", 'test');
die "unable to connect to server $DBI::errstr" unless $dbh;
$dbh->do("use sqltest");
$query = "SELECT * FROM testtable";
$sth = $dbh->prepare ($query) or die "prepare failed\n";
$sth->execute( ) or die "unable to execute query $query error $DBI::errstr";
$rows = $sth->rows ;
print "$row rows returned by query\n";
while ( @first = $sth->fetchrow_array ) {
foreach $field (@first) {
print "field: $field\n";
}
}
[root@nagios ~]# ./a
Segmentation fault
[root@nagios ~]#
————————————————————————————————————————————
/etc/freetds.conf文件内容为:
[sql1]
host = fabu
port = 1433
tds version = 4.2
——————————————————————————
[root@nagios ~]# ping fabu
PING fabu (192.168.3.235) 56(84) bytes of data.
64 bytes from fabu (192.168.3.235): icmp_seq=0 ttl=128 time=1.81 ms
--- fabu ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 1.810/1.810/1.810/0.000 ms, pipe 2
[root@nagios ~]# |
|