I am having difficulties connecting to Microsoft SQL 2005 from a Perl script. I am using DBI 1.609 with unixODBC 2.2.8 and freeTDS 0.82. The commands isql, tsql -H, and tsql -S all connect successfully and respond as expected to queries, but when I try to connect through DBI, I get the following error: DBI connect('Pansophy','pansophy_reader',...) failed: (no error string) at ./update_pansophy.pl line 98.
I have tried both a ODBC-combined and ODBC-only setups. freetds.conf: [sqlHost] host = mssql.domain.com port = 1433 tds version = 8.0 debug flags = 4FFF odbc.ini: [Pansophy] Driver = FreeTDS Description = Pansophy combined setup Servername = sqlHost Database = pansophy odbcinst.ini: [FreeTDS] Description = FreeTDS unixODBC Driver Driver = /usr/local/lib/libtdsodbc.so FileUsage = 1 Perl Code: my $dbh = DBI->connect("dbi:ODBC:Pansophy", "pansophy_reader", "*********"); I turned on logging, but I am afraid I don't know what to look for. DBI->trace(15); DBI 1.609-ithread default trace level set to 0x0/15 (pid 31540) at update_pansophy.pl line 95 -> DBI->connect(dbi:ODBC:Pansophy, pansophy_reader, ****, HASH(0x8150c10)) -> DBI->install_driver(ODBC) for linux perl=5.008003 pid=31540 ruid=1010 euid=1010 install_driver: DBD::ODBC version 1.22 loaded from /usr/lib/perl5/site_perl/5.8.3/i586-linux-thread-multi/DBD/ODBC.pm New 'DBI::dr' (for DBD::ODBC::dr, parent='', id=undef) dbih_setup_handle(DBI::dr=HASH(0x840d730)=>DBI::dr=HASH(0x840d784), DBD::ODBC::dr, 0, Null!) dbih_make_com(Null!, 0, DBD::ODBC::dr, 92, 0) thr#8150008 dbih_setup_attrib(DBI::dr=HASH(0x840d784), Err, Null!) SCALAR(0x834343c) (already defined) dbih_setup_attrib(DBI::dr=HASH(0x840d784), State, Null!) SCALAR(0x8343484) (already defined) dbih_setup_attrib(DBI::dr=HASH(0x840d784), Errstr, Null!) SCALAR(0x8343460) (already defined) dbih_setup_attrib(DBI::dr=HASH(0x840d784), TraceLevel, Null!) 0 (already defined) dbih_setup_attrib(DBI::dr=HASH(0x840d784), FetchHashKeyName, Null!) 'NAME' (already defined) <- install_driver= DBI::dr=HASH(0x840d730) >> connect DISPATCH (DBI::dr=HASH(0x840d730) rc2/3 @5 g0 ima8001 pid#31540) at /usr/lib/perl5/site_perl/5.8.3/i586-linux-thread-multi/DBI.pm line 653 !! warn: 0 CLEARED by call to connect method -> connect for DBD::ODBC::dr (DBI::dr=HASH(0x840d730)~0x840d784 'Pansophy' 'pansophy_reader' **** HASH(0x83549e0)) thr#8150008 New 'DBI::db' (for DBD::ODBC::db, parent=DBI::dr=HASH(0x840d784), id=undef) dbih_setup_handle(DBI::db=HASH(0x840fdbc)=>DBI::db=HASH(0x840fd38), DBD::ODBC::db, 838f484, Null!) dbih_make_com(DBI::dr=HASH(0x840d784), 840f778, DBD::ODBC::db, 348, 0) thr#8150008 dbih_setup_attrib(DBI::db=HASH(0x840fd38), Err, DBI::dr=HASH(0x840d784)) SCALAR(0x8392214) (already defined) dbih_setup_attrib(DBI::db=HASH(0x840fd38), State, DBI::dr=HASH(0x840d784)) SCALAR(0x8392274) (already defined) dbih_setup_attrib(DBI::db=HASH(0x840fd38), Errstr, DBI::dr=HASH(0x840d784)) SCALAR(0x8392244) (already defined) dbih_setup_attrib(DBI::db=HASH(0x840fd38), TraceLevel, DBI::dr=HASH(0x840d784)) 0 (already defined) dbih_setup_attrib(DBI::db=HASH(0x840fd38), FetchHashKeyName, DBI::dr=HASH(0x840d784)) 'NAME' (already defined) dbih_setup_attrib(DBI::db=HASH(0x840fd38), HandleSetErr, DBI::dr=HASH(0x840d784)) undef (not defined) dbih_setup_attrib(DBI::db=HASH(0x840fd38), HandleError, DBI::dr=HASH(0x840d784)) undef (not defined) dbih_setup_attrib(DBI::db=HASH(0x840fd38), ReadOnly, DBI::dr=HASH(0x840d784)) undef (not defined) dbih_setup_attrib(DBI::db=HASH(0x840fd38), Profile, DBI::dr=HASH(0x840d784)) undef (not defined) SQLDriverConnect failed: !!dbd_error2(err_rc=-2, what=post_connect/SQLSetConnectAttr(SQL_AUTOCOMMIT), handles=(8411430,84119c0,0) >> DESTROY DISPATCH (DBI::db=HASH(0x840fdbc) rc1/1 @1 g0 ima10004 pid#31540) at /usr/lib/perl5/site_perl/5.8.3/i586-linux-thread-multi/DBI.pm line 653 <> DESTROY(DBI::db=HASH(0x840fdbc)) ignored for outer handle (inner DBI::db=HASH(0x840fd38) has ref cnt 1) >> DESTROY DISPATCH (DBI::db=HASH(0x840fd38) rc1/1 @1 g0 ima10004 pid#31540) at /usr/lib/perl5/site_perl/5.8.3/i586-linux-thread-multi/DBI.pm line 653 -> DESTROY for DBD::ODBC::db (DBI::db=HASH(0x840fd38)~INNER) thr#8150008 DESTROY for DBI::db=HASH(0x840fd38) ignored - handle not initialised <- DESTROY= undef at /usr/lib/perl5/site_perl/5.8.3/i586-linux-thread-multi/DBI.pm line 653 DESTROY (dbih_clearcom) (dbh 0x840fd38, com 0x8410cb8, imp DBD::ODBC::db): FLAGS 0x100011: COMSET Warn PrintWarn PARENT DBI::dr=HASH(0x840d784) KIDS 0 (0 Active) dbih_clearcom 0x840fd38 (com 0x8410cb8, type 2) done. <- connect= undef at /usr/lib/perl5/site_perl/5.8.3/i586-linux-thread-multi/DBI.pm line 653 -> $DBI::errstr (&) FETCH from lasth=HASH >> DBD::ODBC::dr::errstr <- $DBI::errstr= undef DBI connect('Pansophy','pansophy_reader',...) failed: (no error string) DBI connect('Pansophy','pansophy_reader',...) failed: (no error string) at ./update_pansophy.pl line 98 -- DBI::END ($@: , $!: ) >> disconnect_all DISPATCH (DBI::dr=HASH(0x840d730) rc1/3 @1 g0 ima801 pid#31540) at /usr/lib/perl5/site_perl/5.8.3/i586-linux-thread-multi/DBI.pm line 732 via at ./update_pansophy.pl line 0 -> disconnect_all for DBD::ODBC::dr (DBI::dr=HASH(0x840d730)~0x840d784) thr#8150008 <- disconnect_all= '' at /usr/lib/perl5/site_perl/5.8.3/i586-linux-thread-multi/DBI.pm line 732 via at ./update_pansophy.pl line 0 ! >> DESTROY DISPATCH (DBI::dr=HASH(0x840d730) rc1/1 @1 g0 ima10004 pid#31540) during global destruction ! <> DESTROY(DBI::dr=HASH(0x840d730)) ignored for outer handle (inner DBI::dr=HASH(0x840d784) has ref cnt 1) ! >> DESTROY DISPATCH (DBI::dr=HASH(0x840d784) rc1/1 @1 g0 ima10004 pid#31540) during global destruction ! -> DESTROY in DBD::_::common for DBD::ODBC::dr (DBI::dr=HASH(0x840d784)~INNER) thr#8150008 ! <- DESTROY= undef during global destruction DESTROY (dbih_clearcom) (drh 0x840d784, com 0x840f778, imp global destruction): FLAGS 0x100215: COMSET Active Warn PrintWarn AutoCommit PARENT undef KIDS 0 (0 Active) dbih_clearcom 0x840d784 (com 0x840f778, type 1) done. freetds.log: log.c:190:Starting log file for FreeTDS 0.82 on 2009-07-27 14:50:05 with debug flags 0x4fff. iconv.c:197:names for ISO-8859-1: ISO-8859-1 iconv.c:197:names for UTF-8: UTF-8 iconv.c:197:names for UCS-2LE: UCS-2LE iconv.c:197:names for UCS-2BE: UCS-2BE iconv.c:363:iconv to convert client-side data to the "ISO-8859-1" character set iconv.c:516:tds_iconv_info_init: converting "ISO-8859-1"->"UCS-2LE" iconv.c:516:tds_iconv_info_init: converting "ISO-8859-1"->"UCS-2LE" net.c:210:Connecting to 140.***.***.*** port 1433 (TDS version 8.0) net.c:264:tds_open_socket: connect(2) returned "Operation now in progress" net.c:303:tds_open_socket() succeeded util.c:162:Changed query state from DEAD to IDLE login.c:735:quietly sending TDS 7+ login packet token.c:312:tds_process_login_tokens() net.c:592:Received header 0000 04 01 01 79 00 d2 01 00- |...y....| net.c:671:Received packet 0000 e3 1f 00 01 08 70 00 61-00 6e 00 73 00 6f 00 70 |.....p.a .n.s.o.p| 0010 00 68 00 79 00 06 6d 00-61 00 73 00 74 00 65 00 |.h.y..m. a.s.t.e.| 0020 72 00 ab 66 00 45 16 00-00 02 00 27 00 43 00 68 |r..f.E.. ...'.C.h| 0030 00 61 00 6e 00 67 00 65-00 64 00 20 00 64 00 61 |.a.n.g.e .d. .d.a| 0040 00 74 00 61 00 62 00 61-00 73 00 65 00 20 00 63 |.t.a.b.a .s.e. .c| 0050 00 6f 00 6e 00 74 00 65-00 78 00 74 00 20 00 74 |.o.n.t.e .x.t. .t| 0060 00 6f 00 20 00 27 00 70-00 61 00 6e 00 73 00 6f |.o. .'.p .a.n.s.o| 0070 00 70 00 68 00 79 00 27-00 2e 00 06 4d 00 53 00 |.p.h.y.' ....M.S.| 0080 57 00 53 00 51 00 4c 00-00 01 00 e3 08 00 07 05 |W.S.Q.L. ........| 0090 09 04 d0 00 34 00 e3 17-00 02 0a 75 00 73 00 5f |....4... ...u.s._| 00a0 00 65 00 6e 00 67 00 6c-00 69 00 73 00 68 00 00 |.e.n.g.l .i.s.h..| 00b0 ab 66 00 47 16 00 00 01-00 27 00 43 00 68 00 61 |.f.G.... .'.C.h.a| 00c0 00 6e 00 67 00 65 00 64-00 20 00 6c 00 61 00 6e |.n.g.e.d . .l.a.n| 00d0 00 67 00 75 00 61 00 67-00 65 00 20 00 73 00 65 |.g.u.a.g .e. .s.e| 00e0 00 74 00 74 00 69 00 6e-00 67 00 20 00 74 00 6f |.t.t.i.n .g. .t.o| 00f0 00 20 00 75 00 73 00 5f-00 65 00 6e 00 67 00 6c |. .u.s._ .e.n.g.l| 0100 00 69 00 73 00 68 00 2e-00 06 4d 00 53 00 57 00 |.i.s.h.. ..M.S.W.| 0110 53 00 51 00 4c 00 00 01-00 ad 36 00 01 71 00 00 |S.Q.L... ..6..q..| 0120 01 16 4d 00 69 00 63 00-72 00 6f 00 73 00 6f 00 |..M.i.c. r.o.s.o.| 0130 66 00 74 00 20 00 53 00-51 00 4c 00 20 00 53 00 |f.t. .S. Q.L. .S.| 0140 65 00 72 00 76 00 65 00-72 00 00 00 00 00 09 00 |e.r.v.e. r.......| 0150 0b e2 e3 13 00 04 04 34-00 30 00 39 00 36 00 04 |.......4 .0.9.6..| 0160 34 00 30 00 39 00 36 00-fd 00 00 00 00 00 00 00 |4.0.9.6. ........| 0170 00 - |.| token.c:316:looking for login token, got e3(ENVCHANGE) token.c:108:tds_process_default_tokens() marker is e3(ENVCHANGE) token.c:316:looking for login token, got ab(INFO) token.c:108:tds_process_default_tokens() marker is ab(INFO) token.c:2451:tds_process_msg() reading message from server token.c:2516:tds_process_msg() calling client msg handler odbc.c:2032:msgno 5701 20003 token.c:2529:tds_process_msg() returning TDS_SUCCEED token.c:316:looking for login token, got e3(ENVCHANGE) token.c:108:tds_process_default_tokens() marker is e3(ENVCHANGE) token.c:2281:tds_process_env_chg(): 5 bytes of collation data received token.c:2282:tds->collation was 0000 00 00 00 00 00 - |.....| iconv.c:985:setting server single-byte charset to "CP1252" iconv.c:516:tds_iconv_info_init: converting "ISO-8859-1"->"CP1252" token.c:2292:tds->collation now 0000 09 04 d0 00 34 - |....4| token.c:316:looking for login token, got e3(ENVCHANGE) token.c:108:tds_process_default_tokens() marker is e3(ENVCHANGE) token.c:316:looking for login token, got ab(INFO) token.c:108:tds_process_default_tokens() marker is ab(INFO) token.c:2451:tds_process_msg() reading message from server token.c:2516:tds_process_msg() calling client msg handler odbc.c:2032:msgno 5703 20003 token.c:2529:tds_process_msg() returning TDS_SUCCEED token.c:316:looking for login token, got ad(LOGINACK) token.c:316:looking for login token, got e3(ENVCHANGE) token.c:108:tds_process_default_tokens() marker is e3(ENVCHANGE) token.c:316:looking for login token, got fd(DONE) token.c:108:tds_process_default_tokens() marker is fd(DONE) token.c:2201:tds_process_end: more_results = 0 was_cancelled = 0 error = 0 done_count_valid = 0 token.c:2217:tds_process_end() state set to TDS_IDLE token.c:2232: rows_affected = 0 token.c:393:leaving tds_process_login_tokens() returning 1 odbc.c:4672:SQLGetFunctions: fFunction is 999 odbc.c:5587:SQLGetInfo(0x8425750, 77, 0xbfffc2b0, 20, (nil)) odbc.c:4841:_SQLGetInfo(0x8425750, 77, 0xbfffc2b0, 20, (nil) odbc.c:5587:SQLGetInfo(0x8425750, 10000, 0xbfffc2b0, 5, (nil)) odbc.c:4841:_SQLGetInfo(0x8425750, 10000, 0xbfffc2b0, 5, (nil) odbc.c:5909:SQLSetConnectAttr(0x8411d08, 102, 0x1, 0) odbc.c:3680:SQLFreeHandle(2, 0x0x8411d08) odbc.c:3680:SQLFreeHandle(1, 0x0x8411778) Does anyone have any suggestions to help determine what the problem may be? Thank you so much. Michael Thompson