Skip to Content.
Sympa Menu

freetds - [freetds] ODBC connection problem

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Dominic Smith <d.smith AT querix.co.uk>
  • To: <freetds AT lists.ibiblio.org>
  • Subject: [freetds] ODBC connection problem
  • Date: Wed, 26 Sep 2007 16:43:26 +0100

Hi,

I'm encountering a problem with the stable cut of TDS 0.64 connecting through
ODBC which I can't seem to put right myself, so ...

Using either unixODBC or iODBC driver managers, connecting to SQL Server 2000
hosted on XP/SP2 from Redhat 7.3 (glibc 2.2.5). The connection seems to work
fine from tsql, but consistently fails from odbc regardless of whether or not
I
use ODBC-only configuration.

Dumping TDS is showing the following on the failure (ODBC connection):

util.c:288:Starting log file for FreeTDS 0.64
on 2007-09-26 15:58:20 with debug flags 0x4fff.
iconv.c:195:names for ISO-8859-1: ISO-8859-1
iconv.c:195:names for UTF-8: UTF-8
iconv.c:195:names for UCS-2LE: UCS-2LE
iconv.c:195:names for UCS-2BE: UCS-2BE
iconv.c:361:iconv to convert client-side data to the "ISO-8859-1" character
set
iconv.c:514:tds_iconv_info_init: converting "ISO-8859-1"->"UCS-2LE"
net.c:168:Connecting to 192.168.2.22 port 1433.
net.c:673:Sending packet
0000 02 00 02 00 00 00 00 00-65 74 68 65 6c 00 00 00 |........ ethel...|
0010 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0020 00 00 00 00 00 00 05 73-61 00 00 00 00 00 00 00 |.......s a.......|
0030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0040 00 00 00 00 00 02 00 00-00 00 00 00 00 00 00 00 |........ ........|
0050 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0060 00 00 00 00 00 33 37 38-37 36 00 00 00 00 00 00 |.....378 76......|
0070 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0080 00 00 00 05 03 01 06 0a-09 01 00 00 00 00 00 00 |........ ........|
0090 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
00a0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
00b0 00 00 00 63 6f 6c 75 6d-62 69 61 00 00 00 00 00 |...colum bia.....|
00c0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
00d0 00 08 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
00e0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
00f0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0100 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0110 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0120 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0130 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0140 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0150 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0160 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0170 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0180 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0190 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01a0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01b0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01c0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01d0 00 02 05 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01e0 00 05 00 00 00 00 0d 11-75 73 5f 65 6e 67 6c 69 |........ us_engli|
01f0 73 68 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |sh...... ........|
net.c:673:Sending packet
0000 02 01 00 61 00 00 00 00-00 00 00 00 00 00 0a 00 |...a.... ........|
0010 00 00 00 00 00 00 00 00-00 00 00 00 00 69 73 6f |........ .....iso|
0020 38 38 35 39 31 35 00 00-00 00 00 00 00 00 00 00 |885915.. ........|
0030 00 00 00 00 00 00 00 00-00 00 00 09 01 35 31 32 |........ .....512|
0040 00 00 00 03 00 00 00 00-e2 16 00 01 09 00 00 06 |........ â.......|
0050 6d 7f ff ff ff fe 02 09-00 00 00 00 0a 68 00 00 |m.ÿÿÿþ.. .....h..|
0060 00 - |.|
token.c:310:tds_process_login_tokens()
util.c:119:Changing query state from IDLE to DEAD
token.c:2252:tds_client_msg: #20004: "Read from SQL server failed.".
Connection state is now 4.
token.c:314:looking for login token, got 0()
token.c:105:tds_process_default_tokens() marker is 0()
token.c:108:leaving tds_process_default_tokens() connection dead
util.c:119:Changing query state from DEAD to DEAD
token.c:2252:tds_client_msg: #20014: "Login incorrect.". Connection state is
now 4.
mem.c:519:tds_free_all_results()
odbc.c:3066:SQLFreeHandle(2, 0x0x8088260)
odbc.c:3066:SQLFreeHandle(1, 0x0x80877a0)


Whereas the following dump is obtained through tsql:

util.c:288:Starting log file for FreeTDS 0.64
on 2007-09-26 15:41:43 with debug flags 0x4fff.
iconv.c:195:names for ISO-8859-1: ISO-8859-1
iconv.c:195:names for UTF-8: UTF-8
iconv.c:195:names for UCS-2LE: UCS-2LE
iconv.c:195:names for UCS-2BE: UCS-2BE
iconv.c:361:iconv to convert client-side data to the "ISO-8859-15" character
set
iconv.c:514:tds_iconv_info_init: converting "ISO-8859-15"->"UCS-2LE"
net.c:168:Connecting to 192.168.2.22 port 1433.
net.c:673:Sending packet
0000 02 00 02 00 00 00 00 00-65 74 68 65 6c 00 00 00 |........ ethel...|
0010 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0020 00 00 00 00 00 00 05 73-61 00 00 00 00 00 00 00 |.......s a.......|
0030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0040 00 00 00 00 00 02 00 00-00 00 00 00 00 00 00 00 |........ ........|
0050 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0060 00 00 00 00 00 33 37 38-37 36 00 00 00 00 00 00 |.....378 76......|
0070 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0080 00 00 00 05 03 01 06 0a-09 01 00 00 00 00 02 00 |........ ........|
0090 00 00 00 00 54 53 51 4c-00 00 00 00 00 00 00 00 |....TSQL ........|
00a0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
00b0 00 00 04 63 6f 6c 75 6d-62 69 61 00 00 00 00 00 |...colum bia.....|
00c0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
00d0 00 08 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
00e0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
00f0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0100 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0110 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0120 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0130 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0140 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0150 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0160 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0170 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0180 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
0190 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01a0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01b0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01c0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |........ ........|
01d0 00 00 04 02 00 00 54 44-53 2d 4c 69 62 72 61 72 |......TD S-Librar|
01e0 0a 00 00 00 00 00 0d 11-75 73 5f 65 6e 67 6c 69 |........ us_engli|
01f0 73 68 00 00 00 00 00 00-00 00 00 00 00 00 00 00 |sh...... ........|
net.c:673:Sending packet
0000 02 01 00 4c 00 00 00 00-00 00 00 00 00 00 0a 00 |...L.... ........|
0010 00 00 00 00 00 00 00 00-00 00 00 00 00 69 73 6f |........ .....iso|
0020 38 38 35 39 31 35 00 00-00 00 00 00 00 00 00 00 |885915.. ........|
0030 00 00 00 00 00 00 00 00-00 00 00 09 01 35 31 32 |........ .....512|
0040 00 00 00 03 00 00 00 00-00 00 00 00 |........ ....|
token.c:310:tds_process_login_tokens()
net.c:446:Received header
0000 04 01 00 9b 00 33 01 00- |.....3..|
net.c:542:Received packet
0000 e3 0f 00 01 06 6d 61 73-74 65 72 06 6d 61 73 74 |ã....mas ter.mast|
0010 65 72 ab 39 00 45 16 00-00 02 00 25 00 43 68 61 |er«9.E.. ...%.Cha|
0020 6e 67 65 64 20 64 61 74-61 62 61 73 65 20 63 6f |nged dat abase co|
0030 6e 74 65 78 74 20 74 6f-20 27 6d 61 73 74 65 72 |ntext to 'master|
0040 27 2e 08 43 4f 4c 55 4d-42 49 41 00 00 00 e3 09 |'..COLUM BIA...ã.|
0050 00 03 05 69 73 6f 5f 31-01 00 ad 20 00 01 04 02 |...iso_1 ..­ ....|
0060 00 00 16 4d 69 63 72 6f-73 6f 66 74 20 53 51 4c |...Micro soft SQL|
0070 20 53 65 72 76 65 72 00-00 5f 08 00 c2 e3 0a 00 | Server. ._..Âã..|
0080 04 03 35 31 32 04 34 30-39 36 fd 00 00 00 00 00 |..512.40 96ý.....|
0090 00 00 00 - |...|

... snipped out the continuing success.

ODBC tracing typically isn't showing a great deal of information:

** iODBC Trace file
** Trace started on Wed Sep 26 15:51:01 2007
** Driver Manager: 03.52.0406.0126

[000000.010997]
t 00000000 EXIT SQLDriverConnect with return code -1
(SQL_ERROR)
SQLHDBC 0x805bf78
SQLPOINTER 0x0
SQLCHAR * 0xbfffa8d0
SQLSMALLINT 25
SQLCHAR * 0xbfffd900
SQLSMALLINT 1024
SQLSMALLINT * 0xbfffd0fe
SQLUSMALLINT 0 (SQL_DRIVER_NOPROMPT)
[000000.011131]
t 00000000 ENTER SQLGetDiagField
SQLSMALLINT 2 (SQL_HANDLE_DBC)
SQLHDBC 0x805bf78
SQLSMALLINT 0
SQLUSMALLINT 2 (SQL_DIAG_NUMBER)
SQLPOINTER 0xbfff5c58
SQLINTEGER * -6 (SQL_IS_INTEGER)
SQLSMALLINT * 0x0
[000000.011231]
t 00000000 EXIT SQLGetDiagField with return code -1 (SQL_ERROR)
SQLSMALLINT 2 (SQL_HANDLE_DBC)
SQLHDBC 0x805bf78
SQLSMALLINT 0
SQLUSMALLINT 2 (SQL_DIAG_NUMBER)
SQLPOINTER 0xbfff5c58
SQLINTEGER * -6 (SQL_IS_INTEGER)
SQLSMALLINT * 0x0

... the rest follows with various diagnostic calls, nothing of excitement
beyond the initial error.

The SQLDriverConnect call is effectively being made as:

SQLDriverConnect(
handle,
NULL,
"DSN=sqlserver;Uid=sa;Pwd=",
25, /* well, the length of the connection string above */
some_buffer,
sizeof(some_buffer),
&siz,
SQL_DRIVER_NOPROMPT);

This is embedded in a fairly monolithic interface library, but I should be
able
to extract a simple testcase from this if required.

In the odbc.ini file, the DSN is defined as:

[sqlserver]
Driver=/imports/resources/ODBC/32/lnx/libtdsodbc.so
Description=SQL Server on columbia
Server=columbia
Database=stores
Port=1433
TDS_Version=5.0

I know I had TDS version 0.63 working in the past between the two same
machines, but this was a very long time ago, so no idea what might have
changed
on our side since then. Any ideas what I'm doing wrong?




Archive powered by MHonArc 2.6.24.

Top of Page