Skip to Content.
Sympa Menu

freetds - [freetds] issues connecting with perl DBD::ODBC

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Kulik, Scott" <SKulik AT severstalna.com>
  • To: <freetds AT lists.ibiblio.org>
  • Subject: [freetds] issues connecting with perl DBD::ODBC
  • Date: Fri, 19 Jun 2009 17:19:31 -0400

Hi,



I am trying to connect to a SQL Server from perl. I have successfully
configured ODBC and freetds under Redhat Linux ES4 and am able to
connect with tsql and isql. For some reason though, the test perl
connection script is coming back with an error.



Here is my info:



[root@trafficdev1 root]# cat /etc/odbc.ini

[PTT]

Driver = FreeTDS

Description = ODBC via FreeTDS

Servername = SPT-SQL02

Database = PTT



[root@trafficdev1 root]# cat /etc/odbcinst.ini

# Driver from freetds package

[FreeTDS]

Description = ODBC for SQL Server

Driver = /usr/local/lib/libtdsodbc.so

Setup = /usr/lib/libtdsS.so



/usr/local/etc/freetds.conf

[SPT-SQL02]

host = SPT-SQL02.DOMAIN.COM

port = 1433

tds version = 8.0

client charset = UTF-8



Here is the sample perl script I am using from the freetds site:



#!/usr/bin/perl



use DBI;



my $dbh = DBI->connect('dbi:ODBC:PTT', 'user', 'pass', {PrintError =>
0});



die "Unable for connect to server $DBI::errstr"

unless $dbh;



my $rc;

my $sth;



$sth = $dbh->prepare("select \@\@servername");

if($sth->execute) {

while(@dat = $sth->fetchrow) {

print "@dat\n";

}

}



Here is the output from the script:

[root@trafficdev1 root]# ./test_odbc.pl

Unable for connect to server at ./test_odbc.pl line 7.



I have been playing around with different perl scripts for a while now
but haven't had any success yet. I would really appreciate if anyone
else has some ideas. Thanks!



Scott K





Archive powered by MHonArc 2.6.24.

Top of Page