[freetds] issues connecting with perl DBD::ODBC

Kulik, Scott SKulik at severstalna.com
Tue Jun 23 17:59:16 EDT 2009

Wow...this is really frustrating.  I thought this would be the easiest
step.  I double checked the messages logs which didn't have any errors
and SELinux is already off.

I attempted to redo my configuration based on the config files below.  I
can even setup an ODBC only config without using freetds.conf but I'm
still having the same issue. (even though I can connect and query using
isql no problem)

For some reason if I specify my $dbh like the following:

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

die "Unable for connect to server $DBI::errstr" unless $dbh;

the errstr is always blank.  However, if I make a single change to
anything....DSN name, server name in config files or user/pass then I
get an error message.

If I try to use a format similar to:

my $dbh = DBI->connect("dbi:ODBC:$DSN",'_user','_pass');

like mentioned in the last response I always get a segmentation fault.
Here is one of the combinations I tried:

my $dbh = DBI->connect("dbi:ODBC:$DSN", 'user', 'pass', {PrintError =>

I also setup a test SQL Server 2008 database and reran make test for
DBD::ODBC and everything looked great!

Here is the last odbc.ini config file I used without using freetds.conf:

[root at trafficdev1 root]# cat /etc/odbc.ini
Trace = yes
TraceFile       = /tmp/odbc.log

Driver                  = FreeTDS
Description             = ODBC via FreeTDS
Trace                   = yes
TraceFile               = /tmp/ptt.log
Server                  = SPT-SQL02.DOMAIN.COM
Trusted Connection      = no
Port                    = 1433
Database                = PTT
TDS_Version             = 8.0

And the odbcinst.ini:
; Driver from freetds package
Description     = ODBC for SQL Server
Driver = /usr/local/lib/libtdsodbc.so

I have the latest freetds installed and the following ODBC rpm's

perl v5.8.0 and the following DBI mods:

DBD::ODBC -- 1.22
DBD::Oracle -- 1.15
DBD::mysql -- 4.010
DBI -- 1.43

I'm up for anything else someone can think of!

Thanks for all the replies so far.

Scott k

-----Original Message-----
From: freetds-bounces at lists.ibiblio.org
[mailto:freetds-bounces at lists.ibiblio.org] On Behalf Of Michael Higgins
Sent: Tuesday, June 23, 2009 11:33 AM
To: freetds at lists.ibiblio.org
Subject: Re: [freetds] issues connecting with perl DBD::ODBC

On Tue, 23 Jun 2009 11:03:10 -0400
"Kulik, Scott" <SKulik at severstalna.com> wrote:

> Anyone have any luck getting connected to a SQL server database with
> DBD::ODBC in perl?  I'm hoping to try to get this issue fixed this
> week but I'm out of ideas.

Ah, joy. Just re-joined the list. Glad to see things are much the same.

DBD::ODBC connection is totally possible and entirely opaque by

Here are my configs for you to compare.

# A typical Microsoft SQL Server 2000 configuration
	host = localhost
#	port =1799 
	tds version = 7.0
	dump file = /home/mykhyggz/Desktop/freetds.log 

[ODBC Data Sources]
TREX = Microsoft SQL Server 2000 

Trace = yes
TraceFile	= /home/mykhyggz/Desktop/odbc.log 

Driver          = /usr/lib/libtdsodbc.so
Description     = TREX Data
Trace           = Yes
TraceFile	= /home/mykhyggz/Desktop/trex.log 
Server          =
Trusted Connection = no 
Port		= 1799 
Database        = TREX 
TDS_Version     = 7.0 

Driver          = /usr/lib/libtdsodbc.so 

Driver		= /usr/lib/libtdsodbc.so

Description		= v0.63 with protocol v7.0
Driver		= /usr/lib/libtdsodbc.so
;Setup 	= /usr/lib/libtdsS.so
;UsageCount		= 2
And a working connect string:

my $dbh = DBI->connect("dbi:ODBC:$DSN",'_user','_pass');

Probably there is something about having the Driver= line in there. Note
I have an SSH tunnel from my machine on port 1799 through another linux
box to the server.



 |\  /|        |   |          ~ ~  
 | \/ |        |---|          `|` ?
 |    |ichael  |   |iggins    \^ /
FreeTDS mailing list
FreeTDS at lists.ibiblio.org

More information about the FreeTDS mailing list