Discussion:
[freetds] [unixODBC][FreeTDS][SQL Server]Unable to connect to data source (SQL-08001)
Sankar G
2012-12-13 13:04:49 UTC
Permalink
Hi

I am getting some errors when i am trying to connect MS SqlServer using
FreeTDS,
unixODBC and DBD::ODBC.

My odbcinst.ini file

[FreeTDS]
Description = TDS driver (Sysbase/MS SQL)
Driver = /usr/local/freetds/lib/libtdsodbc.so
Setup = /usr/local/freetds/lib/libtdsodbc.so UsageCount = 1

My odbc.ini file

[SERVER]
Driver = FreeTDS
Description = ODBC connection via FreeTDS
ServerName = SERVER

My freetds.conf file

# A typical Microsoft server
[SERVER]
host = xxx.xxx.xxx.xxx
port = 1433
tds version = 7.2

my perl file

$ perl DB_Test.pl


$dsn = "dbi:ODBC:DRIVER={FreeTDS};Server=$server;database=$database;";
$dbh = DBI->connect("$dsn","$user","$password") or die "\n$DBI::errstr\n";


Error


DBI
connect('DRIVER={FreeTDS};Server=xxx.xxx.xxx.xxx;database=xxxxx;','xxxxxx',...)
failed: [unixODBC][FreeTDS][SQL Server]Unable to connect to data source
(SQL-08001) at DB_Test.pl line 14

[unixODBC][FreeTDS][SQL Server]Unable to connect to data source (SQL-08001)



when i try to connect using osql i am getting this error

$ sudo TDSVER=7.2 osql -S SERVER -U username -P password
checking shared odbc libraries linked to isql for default directories...
trying /usr ... no
trying /loc ... no
trying /tmp/sql.log ... no
trying /home ... no
trying /.odbc.ini ... no
trying /usr/local/etc ... OK
checking odbc.ini files
reading /home/perlzuser/.odbc.ini
[SERVER] not found in /home/perlzuser/.odbc.ini
reading /usr/local/etc/odbc.ini
[SERVER] found in /usr/local/etc/odbc.ini
found this section:
[SERVER]
Driver = FreeTDS
Description = ODBC connection via FreeTDS
ServerName = SERVER

looking for driver for DSN [SERVER] in /usr/local/etc/odbc.ini
found driver line: " Driver = FreeTDS"
driver "FreeTDS" found for [SERVER] in odbc.ini
found driver named "FreeTDS"
"FreeTDS" is not an executable file
looking for entry named [FreeTDS] in /usr/local/etc/odbcinst.ini
found driver line: " Driver = /usr/local/freetds/lib/libtdsodbc.so"
found driver /usr/local/freetds/lib/libtdsodbc.so for [FreeTDS] in
odbcinst.ini
/usr/local/freetds/lib/libtdsodbc.so is an executable file
Using ODBC-Combined strategy
DSN [SERVER] has servername "" (from /usr/local/etc/odbc.ini)

Please I need help to connect MSSQL Server from my perl program using
FreeTDS
and DBD::ODBC


Thanks
Igor Korot
2012-12-14 08:30:24 UTC
Permalink
Hi,
Google is your friend.
The log you posted is clear enough.

Thank you.
Post by Sankar G
Hi
I am getting some errors when i am trying to connect MS SqlServer using
FreeTDS,
unixODBC and DBD::ODBC.
My odbcinst.ini file
[FreeTDS]
Description = TDS driver (Sysbase/MS SQL)
Driver = /usr/local/freetds/lib/libtdsodbc.so
Setup = /usr/local/freetds/lib/libtdsodbc.so UsageCount = 1
My odbc.ini file
[SERVER]
Driver = FreeTDS
Description = ODBC connection via FreeTDS
ServerName = SERVER
My freetds.conf file
# A typical Microsoft server
[SERVER]
host = xxx.xxx.xxx.xxx
port = 1433
tds version = 7.2
my perl file
$ perl DB_Test.pl
$dsn = "dbi:ODBC:DRIVER={FreeTDS};Server=$server;database=$database;";
$dbh = DBI->connect("$dsn","$user","$password") or die "\n$DBI::errstr\n";
Error
DBI
connect('DRIVER={FreeTDS};Server=xxx.xxx.xxx.xxx;database=xxxxx;','xxxxxx',...)
failed: [unixODBC][FreeTDS][SQL Server]Unable to connect to data source
(SQL-08001) at DB_Test.pl line 14
[unixODBC][FreeTDS][SQL Server]Unable to connect to data source (SQL-08001)
when i try to connect using osql i am getting this error
$ sudo TDSVER=7.2 osql -S SERVER -U username -P password
checking shared odbc libraries linked to isql for default directories...
trying /usr ... no
trying /loc ... no
trying /tmp/sql.log ... no
trying /home ... no
trying /.odbc.ini ... no
trying /usr/local/etc ... OK
checking odbc.ini files
reading /home/perlzuser/.odbc.ini
[SERVER] not found in /home/perlzuser/.odbc.ini
reading /usr/local/etc/odbc.ini
[SERVER] found in /usr/local/etc/odbc.ini
[SERVER]
Driver = FreeTDS
Description = ODBC connection via FreeTDS
ServerName = SERVER
looking for driver for DSN [SERVER] in /usr/local/etc/odbc.ini
found driver line: " Driver = FreeTDS"
driver "FreeTDS" found for [SERVER] in odbc.ini
found driver named "FreeTDS"
"FreeTDS" is not an executable file
looking for entry named [FreeTDS] in /usr/local/etc/odbcinst.ini
found driver line: " Driver = /usr/local/freetds/lib/libtdsodbc.so"
found driver /usr/local/freetds/lib/libtdsodbc.so for [FreeTDS] in
odbcinst.ini
/usr/local/freetds/lib/libtdsodbc.so is an executable file
Using ODBC-Combined strategy
DSN [SERVER] has servername "" (from /usr/local/etc/odbc.ini)
Please I need help to connect MSSQL Server from my perl program using
FreeTDS
and DBD::ODBC
Thanks
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
Sankar G
2012-12-14 12:10:25 UTC
Permalink
Hi

I Googled a lot for this,But didn't get any solution.
I am using ubuntu 12.04 LTS
Sql server 2008 (on my Remote machine)
freetds and unixodbc latest version

I have configured correctly as per the user-guide, But still getting error.

Please help me to get out of this.

Thanks

Igor Korot <ikorot01 <at> gmail.com> writes: > > Hi, > Google is your
friend. > The log you posted is clear enough. > > Thank you. > > On Thu,
Dec 13, 2012 at 5:04 AM, Sankar G <geoinnovate <at> gmail.com
Post by Sankar G
Hi
I am getting some errors when i am trying to connect MS SqlServer using
FreeTDS,
unixODBC and DBD::ODBC.
My odbcinst.ini file
[FreeTDS]
Description = TDS driver (Sysbase/MS SQL)
Driver = /usr/local/freetds/lib/libtdsodbc.so
Setup = /usr/local/freetds/lib/libtdsodbc.so UsageCount = 1
My odbc.ini file
[SERVER]
Driver = FreeTDS
Description = ODBC connection via FreeTDS
ServerName = SERVER
My freetds.conf file
# A typical Microsoft server
[SERVER]
host = xxx.xxx.xxx.xxx
port = 1433
tds version = 7.2
my perl file
$ perl DB_Test.pl
$dsn = "dbi:ODBC:DRIVER={FreeTDS};Server=$server;database=$database;";
$dbh = DBI->connect("$dsn","$user","$password") or die
"\n$DBI::errstr\n";
Post by Sankar G
Error
DBI
connect('DRIVER={FreeTDS};Server=xxx.xxx.xxx.xxx;database=xxxxx;','xxxxxx',...)
Post by Sankar G
failed: [unixODBC][FreeTDS][SQL Server]Unable to connect to data source
(SQL-08001) at DB_Test.pl line 14
[unixODBC][FreeTDS][SQL Server]Unable to connect to data source (SQL-08001)
when i try to connect using osql i am getting this error
$ sudo TDSVER=7.2 osql -S SERVER -U username -P password
checking shared odbc libraries linked to isql for default directories...
trying /usr ... no
trying /loc ... no
trying /tmp/sql.log ... no
trying /home ... no
trying /.odbc.ini ... no
trying /usr/local/etc ... OK
checking odbc.ini files
reading /home/perlzuser/.odbc.ini
[SERVER] not found in /home/perlzuser/.odbc.ini
reading /usr/local/etc/odbc.ini
[SERVER] found in /usr/local/etc/odbc.ini
[SERVER]
Driver = FreeTDS
Description = ODBC connection via FreeTDS
ServerName = SERVER
looking for driver for DSN [SERVER] in /usr/local/etc/odbc.ini
found driver line: " Driver = FreeTDS"
driver "FreeTDS" found for [SERVER] in odbc.ini
found driver named "FreeTDS"
"FreeTDS" is not an executable file
looking for entry named [FreeTDS] in /usr/local/etc/odbcinst.ini
found driver line: " Driver = /usr/local/freetds/lib/libtdsodbc.so"
found driver /usr/local/freetds/lib/libtdsodbc.so for [FreeTDS] in
odbcinst.ini
/usr/local/freetds/lib/libtdsodbc.so is an executable file
Using ODBC-Combined strategy
DSN [SERVER] has servername "" (from /usr/local/etc/odbc.ini)
Please I need help to connect MSSQL Server from my perl program using
FreeTDS
and DBD::ODBC
Thanks
_______________________________________________
FreeTDS mailing list
FreeTDS <at> lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
Frediano Ziglio
2012-12-14 13:50:05 UTC
Permalink
Hi,
well, odbc world is not that easy, at least in configuration stuff.

FreeTDS has its configuration (freetds.conf). ODBC configuration could
be either DSN based or connection string based (this is true even for
Windows) and you can also have a connection string based that points
to your DSN. Adding FreeTDS to odbc make things more complicated as
your DSN or your connection string can point to FreeTDS configuration.

Now your files seem to indicate that your DSN (odbc.ini) points to
FreeTDS (Servername attribute in either connection string or as DSN
entries) however you are using a full connection string in your Perl
program.

So, if your connection line is

$dsn = "dbi:ODBC:DRIVER={FreeTDS};Server=$server;database=$database;";

$server should be a real server (even ip address). If you want to use
your "SERVER" in odbc.ini you have to specify something like

$dsn = "dbi:ODBC:DSN=SERVER;";

or just

$dsn = "dbi:ODBC:SERVER";

You could even specify a full connection string but probably you want
something like

$dsn = "dbi:ODBC:DRIVER={FreeTDS};Server=$server;Port=1433;TDS_Version=7.2;database=$database;";

where $server is an dns hostname or an ip. Note that in this case
odbc.ini and freetds.conf are not used (here odbcinst.ini is used to
find the odbc driver given the name).

Frediano
Post by Sankar G
Hi
I Googled a lot for this,But didn't get any solution.
I am using ubuntu 12.04 LTS
Sql server 2008 (on my Remote machine)
freetds and unixodbc latest version
I have configured correctly as per the user-guide, But still getting error.
Please help me to get out of this.
Thanks
Igor Korot <ikorot01 <at> gmail.com> writes: > > Hi, > Google is your
friend. > The log you posted is clear enough. > > Thank you. > > On Thu,
Dec 13, 2012 at 5:04 AM, Sankar G <geoinnovate <at> gmail.com
Post by Sankar G
Hi
I am getting some errors when i am trying to connect MS SqlServer using
FreeTDS,
unixODBC and DBD::ODBC.
My odbcinst.ini file
[FreeTDS]
Description = TDS driver (Sysbase/MS SQL)
Driver = /usr/local/freetds/lib/libtdsodbc.so
Setup = /usr/local/freetds/lib/libtdsodbc.so UsageCount = 1
My odbc.ini file
[SERVER]
Driver = FreeTDS
Description = ODBC connection via FreeTDS
ServerName = SERVER
My freetds.conf file
# A typical Microsoft server
[SERVER]
host = xxx.xxx.xxx.xxx
port = 1433
tds version = 7.2
my perl file
$ perl DB_Test.pl
$dsn = "dbi:ODBC:DRIVER={FreeTDS};Server=$server;database=$database;";
$dbh = DBI->connect("$dsn","$user","$password") or die
"\n$DBI::errstr\n";
Post by Sankar G
Error
DBI
connect('DRIVER={FreeTDS};Server=xxx.xxx.xxx.xxx;database=xxxxx;','xxxxxx',...)
Post by Sankar G
failed: [unixODBC][FreeTDS][SQL Server]Unable to connect to data source
(SQL-08001) at DB_Test.pl line 14
[unixODBC][FreeTDS][SQL Server]Unable to connect to data source
(SQL-08001)
Post by Sankar G
when i try to connect using osql i am getting this error
$ sudo TDSVER=7.2 osql -S SERVER -U username -P password
checking shared odbc libraries linked to isql for default directories...
trying /usr ... no
trying /loc ... no
trying /tmp/sql.log ... no
trying /home ... no
trying /.odbc.ini ... no
trying /usr/local/etc ... OK
checking odbc.ini files
reading /home/perlzuser/.odbc.ini
[SERVER] not found in /home/perlzuser/.odbc.ini
reading /usr/local/etc/odbc.ini
[SERVER] found in /usr/local/etc/odbc.ini
[SERVER]
Driver = FreeTDS
Description = ODBC connection via FreeTDS
ServerName = SERVER
looking for driver for DSN [SERVER] in /usr/local/etc/odbc.ini
found driver line: " Driver = FreeTDS"
driver "FreeTDS" found for [SERVER] in odbc.ini
found driver named "FreeTDS"
"FreeTDS" is not an executable file
looking for entry named [FreeTDS] in /usr/local/etc/odbcinst.ini
found driver line: " Driver = /usr/local/freetds/lib/libtdsodbc.so"
found driver /usr/local/freetds/lib/libtdsodbc.so for [FreeTDS] in
odbcinst.ini
/usr/local/freetds/lib/libtdsodbc.so is an executable file
Using ODBC-Combined strategy
DSN [SERVER] has servername "" (from /usr/local/etc/odbc.ini)
Please I need help to connect MSSQL Server from my perl program using
FreeTDS
and DBD::ODBC
Thanks
_______________________________________________
FreeTDS mailing list
FreeTDS <at> lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
Frediano Ziglio
2012-12-14 13:50:48 UTC
Permalink
See also http://www.freetds.org/userguide/odbcconnattr.htm
Post by Sankar G
Hi
I Googled a lot for this,But didn't get any solution.
I am using ubuntu 12.04 LTS
Sql server 2008 (on my Remote machine)
freetds and unixodbc latest version
I have configured correctly as per the user-guide, But still getting error.
Please help me to get out of this.
Thanks
Igor Korot <ikorot01 <at> gmail.com> writes: > > Hi, > Google is your
friend. > The log you posted is clear enough. > > Thank you. > > On Thu,
Dec 13, 2012 at 5:04 AM, Sankar G <geoinnovate <at> gmail.com
Post by Sankar G
Hi
I am getting some errors when i am trying to connect MS SqlServer using
FreeTDS,
unixODBC and DBD::ODBC.
My odbcinst.ini file
[FreeTDS]
Description = TDS driver (Sysbase/MS SQL)
Driver = /usr/local/freetds/lib/libtdsodbc.so
Setup = /usr/local/freetds/lib/libtdsodbc.so UsageCount = 1
My odbc.ini file
[SERVER]
Driver = FreeTDS
Description = ODBC connection via FreeTDS
ServerName = SERVER
My freetds.conf file
# A typical Microsoft server
[SERVER]
host = xxx.xxx.xxx.xxx
port = 1433
tds version = 7.2
my perl file
$ perl DB_Test.pl
$dsn = "dbi:ODBC:DRIVER={FreeTDS};Server=$server;database=$database;";
$dbh = DBI->connect("$dsn","$user","$password") or die
"\n$DBI::errstr\n";
Post by Sankar G
Error
DBI
connect('DRIVER={FreeTDS};Server=xxx.xxx.xxx.xxx;database=xxxxx;','xxxxxx',...)
Post by Sankar G
failed: [unixODBC][FreeTDS][SQL Server]Unable to connect to data source
(SQL-08001) at DB_Test.pl line 14
[unixODBC][FreeTDS][SQL Server]Unable to connect to data source
(SQL-08001)
Post by Sankar G
when i try to connect using osql i am getting this error
$ sudo TDSVER=7.2 osql -S SERVER -U username -P password
checking shared odbc libraries linked to isql for default directories...
trying /usr ... no
trying /loc ... no
trying /tmp/sql.log ... no
trying /home ... no
trying /.odbc.ini ... no
trying /usr/local/etc ... OK
checking odbc.ini files
reading /home/perlzuser/.odbc.ini
[SERVER] not found in /home/perlzuser/.odbc.ini
reading /usr/local/etc/odbc.ini
[SERVER] found in /usr/local/etc/odbc.ini
[SERVER]
Driver = FreeTDS
Description = ODBC connection via FreeTDS
ServerName = SERVER
looking for driver for DSN [SERVER] in /usr/local/etc/odbc.ini
found driver line: " Driver = FreeTDS"
driver "FreeTDS" found for [SERVER] in odbc.ini
found driver named "FreeTDS"
"FreeTDS" is not an executable file
looking for entry named [FreeTDS] in /usr/local/etc/odbcinst.ini
found driver line: " Driver = /usr/local/freetds/lib/libtdsodbc.so"
found driver /usr/local/freetds/lib/libtdsodbc.so for [FreeTDS] in
odbcinst.ini
/usr/local/freetds/lib/libtdsodbc.so is an executable file
Using ODBC-Combined strategy
DSN [SERVER] has servername "" (from /usr/local/etc/odbc.ini)
Please I need help to connect MSSQL Server from my perl program using
FreeTDS
and DBD::ODBC
Thanks
_______________________________________________
FreeTDS mailing list
FreeTDS <at> lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
James K. Lowden
2012-12-15 02:02:59 UTC
Permalink
On Thu, 13 Dec 2012 18:34:49 +0530
Post by Sankar G
Using ODBC-Combined strategy
DSN [SERVER] has servername "" (from /usr/local/etc/odbc.ini)
I'm not sure your connection string is right in your DBD connection,
but it's always a good idea to make test your ODBC setup with osql, as
you did. And it seems you either tickled a bug in osql or maybe
there's something else amiss.

What's odd is that osql finds the right stanza
in /usr/local/etc/odbc.ini:

[SERVER]
Driver = FreeTDS
Description = ODBC connection via FreeTDS
ServerName = SERVER

but then reports:

DSN [SERVER] has servername "" (from /usr/local/etc/odbc.ini)

Looking at the osql script, I can only guess your awk works differently
from mine. What does the following show on your computer? I get:

$ SERVER_LINE='ServerName = SERVER'
$ echo ${SERVER_LINE} | awk -F '=[[:space:]]*' '{print $2}'
SERVER

If yours doesn't also print 'SERVER', we need to modify osql so it
does. If it does print 'SERVER', I don't understand how osql could
find the right line and not parse it correctly.

To isolate yourself from Perl *and* osql bugs, you could always try

$ TDSVER=7.2 bsqlodbc -S SERVER -U username -P password

(sudo shouldn't be necessary.)

HTH.

--jkl

Loading...