Error 20002 tsql

#sql-server #macos #pyodbc #freetds

#sql-server #macos #pyodbc #freetds

#sql-сервер #macos #pyodbc #freetds

Вопрос:

Я использовал это руководство для подключения к базе данных через pyodbc: https://github.com/mkleehammer/pyodbc/wiki/Connecting-to-SQL-Server-from-Mac-OSX

Мои конфигурационные файлы выглядят так, параллельно с учебным пособием: В freetds.conf:

 [MYMSSQL]
host = localhost
port = 1433
tds version = 7.3
 

В odbc.ini:

 [MYMSSQL]
Description         = Testing SQLServer
Driver              = FreeTDS
Servername          = MYMSSQL
 

В odbcinst.ini:

 [FreeTDS]
   Description=FreeTDS Driver for Linux amp; MSSQL
   Driver=/usr/local/lib/libtdsodbc.so
   Setup=/usr/local/lib/libtdsodbc.so
   UsageCount=1
 

Когда я проверяю соединение с помощью «tsql -S MYMSSQL -U myuser -P mypassword», я получаю сообщение об ошибке:

 Error 20002 (severity 9):
    Adaptive Server connection failed
There was a problem connecting to the server
 

Аналогично, «isql MYMSSQL myuser mypassword» также возвращает ошибку:

 [ISQL]ERROR: Could not SQLConnect
 

РЕДАКТИРОВАТЬ: в консоли запросов:

«SELECT @@SERVERNAME» возвращает «4a70ffff1294»

«SELECT @@SERVICENAME» возвращает «MSSQLSERVER»

«ВЫБЕРИТЕ @@VERSION» возвращает «Microsoft SQL Server 2019 (RTM-CU8) (KB4577194) — 15.0.4073.23 (X64)»

 tsql -S MYMSSQL
 

ВОЗВРАТ

 locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Error 20002 (severity 9):
    Adaptive Server connection failed
There was a problem connecting to the server
 

Сервер запущен в образе docker. Я могу подключиться к нему через инструмент базы данных pycharm с помощью порта 1433 и соответствующего пароля. К сожалению, я не очень разбираюсь в управлении серверами. Вся помощь очень ценится.

Комментарии:

1. К какой версии SQL Server вы пытаетесь подключиться? Версия TDS 7.3 относится только к SQL Server 2008, который больше не поддерживается. Вероятно, вы хотите использовать как минимум TDS версии 7.4 для SQL Server 2012 и более поздних версий.

2. TDS 7.1, 7.2, 7.3 и 7.4 будут работать для SQL Server 2008 , но не со всеми новейшими функциями. Его версия FreeTDS может не поддерживать 7.4.

3. Команда «ВЫБРАТЬ @@VERSION» в консоли запросов возвращает «Microsoft SQL Server 2019 (RTM-CU8) (KB4577194) — 15.0.4073.23 (X64) 23 сентября 2020 16:03:08 Авторское право (C) 2019 Microsoft Corporation Developer Edition (64-разрядная версия) на Linux (Ubuntu 18.04.5 LTS) <X64>»

Ответ №1:

Если вы хотите продолжить этот путь, нам понадобится дополнительная информация. Что в вашем freetds.conf ? Можете ли вы подключиться к своему SQL Server с компьютера, на который вы пытаетесь установить FreeTDS telnet mssql.myhost.com 1433 ?

Тем не менее, мне проще избежать использования freetds.conf and odbc.ini и просто сохранить все в Python. Если вы правильно настроили odbcinst.ini , вы должны быть в состоянии сделать что-то вроде этого:

 import pyodbc

con = pyodbc.connect(
    "DRIVER={FreeTDS};"
    "SERVER=mssql.yourserver.com;"
    "PORT=1433;"
    "DATABASE=your_db;"
    "UID=your_user;"
    "PWD=your_pass;"
    "TDS_Version=7.3;"
)
cursor = conn.cursor()

cursor.execute("SELECT 1")

for row in cursor.fetchall():
    print(row)
 

Удачи!

Комментарии:

1. conn = pyodbc.connect( «ДРАЙВЕР ={FreeTDS};» «СЕРВЕР = MYMSSQL;» «ПОРТ = 1433;» «БАЗА ДАННЫХ = ArtGallery;» «UID= SA;» «PWD=4916Hyperbolic *;» «TDS_Version=7.3;» ) возвращает: pyodbc. Операционная ошибка: (‘08001’, ‘[08001] [ FreeTDS][SQL Server]Не удается подключиться к источнику данных (0) (SQLDriverConnect)’)

2. Используйте полное доменное имя, а не MYMSSQL — например, mssql.myserver.com . Или IP-адрес. Кроме того, что происходит, когда вы пытаетесь telnet mssql.myhost.com 1433 выполнить команду на вашем хосте MSSQL? Подключается ли он или просто зависает при попытке?

3. Я заменил «SERVER = MYMSSQL;» на «SERVER = 178.241.125.37;» , который является моим IP-адресом. Теперь он перестает отвечать. Я предполагаю, что он пытается дождаться ответа от сервера? большое спасибо за ваше время btw_

As title, when i use pymssql to connect sql server, it encounters this error:pymssql.OperationalError: (20002, b’DB-Lib error message 20002, severity 9:nAdaptive Server connection failed

Complete log is:

conn = pymssql.connect(host=r»10.106.5.190:1433″,user=r»test»,password=r»test»,database=r»test»)
dblib.c:714:dblogin(void)
dblib.c:769:dbsetlname(00000181DF623DC0, hqfx, 2)
dblib.c:769:dbsetlname(00000181DF623DC0, hqfxmy002714, 3)
dblib.c:769:dbsetlname(00000181DF623DC0, pymssql=2.1.5, 5)
dblib.c:769:dbsetlname(00000181DF623DC0, UTF-8, 10)
dblib.c:769:dbsetlname(00000181DF623DC0, MarketAnalysis, 14)
dblib.c:4245:dbsetlogintime(60)
log.c:168:Starting log file for FreeTDS 1.2.20
on 2021-04-16 11:21:02 with debug flags 0x4fff.
dblib.c:1192:tdsdbopen(00000181DF623DC0, 10.106.5.104:1433, [microsoft])
dblib.c:1218:tdsdbopen: dbproc->dbopts = 00000181DD5C8FC0
dblib.c:1229:tdsdbopen: tds_set_server(00000181DF5F6660, «10.106.5.104:1433»)
dblib.c:251:dblib_get_tds_ctx(void)
dblib.c:1246:tdsdbopen: About to call tds_read_config_info…
config.c:170:Getting connection information for [10.106.5.104:1433].
config.c:174:Attempting to read conf files.
config.c:362:… $FREETDSCONF not set. Trying $FREETDS/etc.
config.c:375:… $FREETDS not set. Trying $HOME.
config.c:301:Could not open ‘C:UserssirzhAppDataRoaming/.freetds.conf’ ((.freetds.conf)).
config.c:301:Could not open ‘c:freetds.conf’ ((default)).
config.c:362:… $FREETDSCONF not set. Trying $FREETDS/etc.
config.c:375:… $FREETDS not set. Trying $HOME.
config.c:301:Could not open ‘C:UserssirzhAppDataRoaming/.freetds.conf’ ((.freetds.conf)).
config.c:301:Could not open ‘c:freetds.conf’ ((default)).
config.c:833:Setting ‘dump_file’ to ‘stdout’ from $TDSDUMP.
config.c:724:tds_config_login: client_charset is UTF-8.
config.c:733:tds_config_login: database_name is MarketAnalysis.
config.c:833:Setting ‘dump_file’ to ‘stdout’ from $TDSDUMP.
dblib.c:1273:tdsdbopen: Calling tds_connect_and_login(00000181DF5FA4D0, 00000181DF5F6990)
iconv.c:365:tds_iconv_open(00000181DD6B80F0, UTF-8)
iconv.c:387:setting up conversions for client charset «UTF-8»
iconv.c:389:preparing iconv for «UTF-8» <-> «UCS-2LE» conversion
iconv.c:428:tds_iconv_open: done
net.c:391:Connecting with protocol version 7.4
net.c:318:Connecting to 10.106.5.104 port 1433
«et.c:340:tds_setup_socket: connect(2) returned «无法立即完成一个非阻止性套接字操作。
net.c:528:tds_open_socket() succeeded
packet.c:852:Sending packet
0000 12 01 00 3a 00 00 00 00-00 00 1a 00 06 01 00 20 |…:…. ……. |
0010 00 01 02 00 21 00 0c 03-00 2d 00 04 04 00 31 00 |….!… .-….1.|
0020 01 ff 09 00 00 00 00 00-00 4d 53 53 51 4c 53 65 |.. ….. .MSSQLSe|
0030 72 76 65 72 00 cc 5f 00-00 00 |rver.._. ..|

packet.c:410:Received packet
0000 04 01 00 2b 00 00 01 00-00 00 1a 00 06 01 00 20 |…+…. ……. |
0010 00 01 02 00 21 00 01 03-00 22 00 00 04 00 22 00 |….!… .»….».|
0020 01 ff 0d 00 06 41 00 00-00 00 00 |…..A.. …|

login.c:1281:detected crypt flag 0
tls.c:1013:setting default openssl cipher to:HIGH:!SSLv2:!aNULL:-DH
tls.c:147:in tds_push_func_login
tls.c:117:in tds_pull_func_login
packet.c:852:Sending packet
0000 12 01 01 4b 00 00 00 00-16 03 01 01 3e 01 00 01 |…K…. ….>…|
0010 3a 03 03 eb 14 13 da 1c-d8 9c a5 7a 14 6e 34 08 |:……. …z.n4.|
0020 1a 59 b7 97 6d 82 9c b9-25 c8 c7 4e 84 c6 8e 7d |.Y..m… %..N…}|
0030 1b b4 8d 20 62 d2 c6 83-72 2f 22 ef e4 ef 95 ae |… b… r/»…..|
0040 7e 82 47 c1 9d f7 99 e3-13 76 d9 9a 81 31 4a e4 |~.G….. .v…1J.|
0050 4d 69 d3 16 00 5c 13 02-13 03 13 01 c0 2c c0 30 |Mi….. …..,.0|
0060 cc a9 cc a8 c0 af c0 ad-c0 5d c0 61 c0 2b c0 2f |…….. .].a.+./|
0070 c0 ae c0 ac c0 5c c0 60-c0 24 c0 28 c0 73 c0 77 |……` .$.(.s.w|
0080 c0 23 c0 27 c0 72 c0 76-c0 0a c0 14 c0 09 c0 13 |.#.’.r.v ….. ..|
0090 00 9d c0 a1 c0 9d c0 51-00 9c c0 a0 c0 9c c0 50 |…….Q …….P|
00a0 00 3d 00 c0 00 3c 00 ba-00 35 00 84 00 2f 00 41 |.=…<.. .5…/.A|
00b0 00 ff 01 00 00 95 00 0b-00 04 03 00 01 02 00 0a |…….. ……..|
00c0 00 0c 00 0a 00 1d 00 17-00 1e 00 19 00 18 00 23 |…….. …….#|
00d0 00 00 00 16 00 00 00 17-00 00 00 0d 00 30 00 2e |…….. …..0..|
00e0 04 03 05 03 06 03 08 07-08 08 08 09 08 0a 08 0b |…….. … ….|
00f0 08 04 08 05 08 06 04 01-05 01 06 01 03 03 02 03 |…….. ……..|
0100 03 01 02 01 03 02 02 02-04 02 05 02 06 02 00 2b |…….. …….+|
0110 00 09 08 03 04 03 03 03-02 03 01 00 2d 00 02 01 |. …… ….-…|
0120 01 00 33 00 26 00 24 00-1d 00 20 db ad b9 7f 88 |..3.&.$. .. …..|
0130 85 15 09 fd a8 23 e3 41-d5 00 a5 95 f6 ed f4 4a |.. ..#.A …….J|
0140 92 d5 94 5a ec 3d 3e 86-59 06 48 |…Z.=>. Y.H|

packet.c:410:Received packet
0000 12 01 04 a0 00 00 00 00-16 03 03 04 93 02 00 00 |…….. ……..|
0010 51 03 03 60 79 02 a0 9d-10 37 d2 14 83 40 87 2c |Q..y... .7...@.,| 0020 6b b8 de 76 b6 ff cc bf-39 54 d3 76 00 86 46 2d |k..v.... 9T.v..F-| 0030 cd 00 c8 20 a3 36 00 00-44 64 f5 0b 5d e1 07 67 |... .6.. Dd..]..g| 0040 98 46 28 6f fd e9 e6 46-43 b6 7c 9d f6 05 3c 57 |.F(o...F C.|...<W| 0050 02 d2 dc 41 c0 30 00 00-09 00 17 00 00 ff 01 00 |...A.0.. .......| 0060 01 00 0b 00 03 0a 00 03-07 00 03 04 30 82 03 00 |........ ....0...| 0070 30 82 01 e8 a0 03 02 01-02 02 10 13 58 b3 05 e1 |0....... ....X...| 0080 ee 0f a2 40 af 3f 36 fc-49 16 c0 30 0d 06 09 2a |...@.?6. I..0.. *| 0090 86 48 86 f7 0d 01 01 05-05 00 30 3b 31 39 30 37 |.H...... ..0;1907| 00a0 06 03 55 04 03 1e 30 00-53 00 53 00 4c 00 5f 00 |..U...0. S.S.L._.| 00b0 53 00 65 00 6c 00 66 00-5f 00 53 00 69 00 67 00 |S.e.l.f. _.S.i.g.| 00c0 6e 00 65 00 64 00 5f 00-46 00 61 00 6c 00 6c 00 |n.e.d._. F.a.l.l.| 00d0 62 00 61 00 63 00 6b 30-20 17 0d 32 31 30 32 30 |b.a.c.k0 ..21020| 00e0 31 30 38 34 39 35 30 5a-18 0f 32 30 35 31 30 32 |1084950Z ..205102| 00f0 30 31 30 38 34 39 35 30-5a 30 3b 31 39 30 37 06 |01084950 Z0;1907.| 0100 03 55 04 03 1e 30 00 53-00 53 00 4c 00 5f 00 53 |.U...0.S .S.L._.S| 0110 00 65 00 6c 00 66 00 5f-00 53 00 69 00 67 00 6e |.e.l.f._ .S.i.g.n| 0120 00 65 00 64 00 5f 00 46-00 61 00 6c 00 6c 00 62 |.e.d._.F .a.l.l.b| 0130 00 61 00 63 00 6b 30 82-01 22 30 0d 06 09 2a 86 |.a.c.k0. ."0.. *.| 0140 48 86 f7 0d 01 01 01 05-00 03 82 01 0f 00 30 82 |H....... ......0.| 0150 01 0a 02 82 01 01 00 e2-a1 b0 0c 98 e5 0b eb 0a |........ ........| 0160 a5 84 7b cc 19 6f 74 46-a7 ec 0a 0b eb 82 95 38 |..{..otF .......8| 0170 e8 c7 0c 0c aa b9 ff 2f-f2 5e 2d f0 93 e0 76 5d |......./ .^-...v]| 0180 2a 69 02 f0 98 e1 19 99-d3 94 f4 25 25 bb e2 a3 |*i...... ...%%...| 0190 32 62 29 eb bc ae ec a2-26 09 7b f4 f1 4c cd 35 |2b)..... & {..L.5| 01a0 e9 f6 9c 10 f4 a4 a8 dc-e8 54 71 64 0d f1 1b 2a |........ .Tqd...*| 01b0 6c 10 d8 2d 55 cb 06 e7-21 88 a9 a8 66 1c 07 d1 |l..-U... !...f...| 01c0 6c ec fb 34 31 63 68 c7-49 d4 2c 42 80 2b 67 f9 |l..41ch. I.,B.+g.| 01d0 0a b0 d8 88 cd d4 06 01-55 c2 98 dc 40 e8 32 d7 |........ U...@.2.| 01e0 b1 47 b5 be b1 13 42 42-56 1c dc 8a f5 64 14 ba |.G....BB V....d..| 01f0 3d 71 9a cf 26 26 e8 19-f9 2f 44 6e 25 03 3e b9 |=q..&&.. ./Dn%.>.| 0200 e1 da 64 1a 74 38 c1 43-e8 bc 08 de 2f 3e 42 04 |..d.t8.C ..../>B.| 0210 36 af 4b 0c 7a 76 31 ac-f8 8e e6 87 5f f8 3e 40 |6.K.zv1. ...._.>@| 0220 22 5d 8b b2 a9 42 43 63-0c ae 41 1e 47 88 5a fc |"]...BCc ..A.G.Z.| 0230 53 b7 e2 29 c2 04 d9 84-23 84 e0 a8 33 3d 08 97 |S..).... #...3=..| 0240 57 12 9b 24 04 4e b7 c4-ec 48 a1 62 7b 24 bc 20 |W..$.N.. .H.b{$. | 0250 eb ae 34 29 a7 c9 33 02-03 01 00 01 30 0d 06 09 |..4)..3. ....0.. | 0260 2a 86 48 86 f7 0d 01 01-05 05 00 03 82 01 01 00 |*.H..... ........| 0270 5a a3 fd cb 7b d6 3f 4b-5a 90 2a 01 dc d3 8b d5 |Z...{.?K Z.*.....| 0280 6f cb fb f4 c9 50 2f d4-47 18 96 03 ee bc 65 1d |o....P/. G.....e.| 0290 57 f2 3a 6d b7 01 71 bc-73 1f 0c b7 60 26 9e ae |W.:m..q. s...&..|
02a0 37 64 a2 d0 d8 dc 1d 53-da c3 60 25 02 a3 33 3f |7d…..S ..%..3?| 02b0 2b e8 9f c0 14 7e 87 2e-20 3e 7c 98 3a 89 30 ad |+....~.. >|.:.0.| 02c0 bc 3f 72 81 66 aa 14 e6-38 a0 7a 2c 7a 8d 14 50 |.?r.f... 8.z,z..P| 02d0 56 8c ac 60 b2 c4 62 00-18 1d 4c d3 5a 44 b9 39 |V....b. ..L.ZD.9|
02e0 26 55 2d 7c 5e 6e 6d c4-90 94 0e 1a 5e af 2b 65 |&U-|^nm. ….^.+e|
02f0 03 a8 92 a9 e8 1d e0 01-da f0 35 76 df 0d 85 44 |…….. ..5v…D|
0300 df c3 e7 b1 f2 f2 7a d6-81 24 fb a2 d2 15 3f 55 |……z. .$….?U|
0310 e4 91 7b 6a ac 6e 9e 72-d7 4e 94 ae 7d a7 fb 2d |..{j.n.r .N..}..-|
0320 64 e2 2c 1e 24 ce 63 98-18 91 75 e7 b4 00 a7 25 |d.,.$.c. ..u….%|
0330 ce dc 24 fb 74 83 28 3e-27 9b 4c e4 dc a1 05 c9 |..$.t.(> ‘.L…..|
0340 8d e6 30 af 31 ab ad 59-8b eb 73 20 59 55 68 b3 |..0.1..Y ..s YUh.|
0350 f9 2d 6d 44 bd 5a d6 9e-21 e5 2a cd e8 47 8f 8c |.-mD.Z.. !.*..G..|
0360 c4 95 a9 93 a6 40 b7 4d-45 3f 07 80 a3 b0 4c c1 |…..@.M E?….L.|
0370 0c 00 01 28 03 00 1d 20-69 2f 3d 4e b4 37 14 73 |…(… i/=N.7.s|
0380 ad 08 7f df f7 16 c8 fe-4b 50 0b 6e a9 02 1c c8 |…….. KP.n….|
0390 a7 94 f5 87 63 e7 8d 3a-04 01 01 00 9c e2 d5 bd |….c..: ……..|
03a0 3b 93 c9 ae f4 ee bb 9b-93 18 47 d3 38 d8 c2 6c |;……. ..G.8..l|
03b0 a2 6b aa e7 60 01 a8 c6-ff 03 53 12 bb 42 58 41 |.k..`… ..S..BXA|
03c0 80 b1 84 7b ae 16 79 78-08 bc b8 87 97 00 c0 83 |…{..yx ……..|
03d0 f5 13 71 1e 30 91 08 3d-90 db ac a2 15 c0 51 5a |..q.0..= ……QZ|
03e0 79 06 f9 ab 1d 80 31 de-7a 81 97 d7 4a 6a d5 30 |y…..1. z…Jj.0|
03f0 3f 57 fe 1e c4 c8 17 32-53 83 99 1e fd 21 cd 81 |?W…..2 S….!..|
0400 92 76 c5 a9 48 1d dd 54-d3 76 1f de c5 6e 33 0b |.v..H..T .v…n3.|
0410 2e ec 62 df 2d 11 37 16-2b 31 fd 2e 24 33 25 f2 |..b.-.7. +1..$3%.|
0420 14 20 9c 9e 41 2d 32 30-0f 8e 8c f6 37 7a 52 10 |. ..A-20 ….7zR.|
0430 dd 3c 39 84 f6 e7 5a 8f-d5 19 94 a9 1d 3a 46 18 |.<9…Z. …..:F.|
0440 d5 08 81 b5 a4 85 30 c5-91 d4 0e ae 04 dd b2 e9 |……0. ……..|
0450 46 98 31 c5 d7 d1 b1 e8-64 51 92 b4 6c 72 f6 52 |F.1….. dQ..lr.R|
0460 9a 2c 97 b7 af 4c f6 7b-51 90 dc b8 4d cc f9 e5 |.,…L.{ Q…M…|
0470 6f c7 00 9f f5 fc 17 f7-f2 25 2b 7f 77 c4 4f 2e |o……. .%+.w.O.|
0480 f5 87 29 c8 47 83 3a 3f-25 03 bd 20 3a f5 b6 56 |..).G.:? %.. :..V|
0490 06 42 09 d4 19 e9 4f 7f-17 a0 41 21 0e 00 00 00 |.B …O. ..A!….|

tls.c:117:in tds_pull_func_login
tls.c:147:in tds_push_func_login
tls.c:117:in tds_pull_func_login
packet.c:852:Sending packet
0000 12 01 00 65 00 00 00 00-16 03 03 00 25 10 00 00 |…e…. ….%…|
0010 21 20 65 ce 31 87 97 f1-06 6e 77 98 0b 9a 7f 94 |! e.1… .nw…..|
0020 da 8c 73 99 94 6a 26 47-b0 48 53 42 d2 4f e4 f8 |..s..j&G .HSB.O..|
0030 59 56 14 03 03 00 01 01-16 03 03 00 28 88 51 26 |YV…… ….(.Q&|
0040 72 83 0d f3 22 f1 12 33-35 00 d8 0b 68 c8 1f 6b |r…»..3 5…h..k|
0050 26 42 e9 bc f7 3e 66 37-21 7d 39 6d 7d 4d b5 7b |&B…>f7 !}9m}M.{|
0060 12 a2 b4 be 67 — |….g|

packet.c:410:Received packet
0000 12 01 00 3b 00 00 00 00-14 03 03 00 01 01 16 03 |…;…. ……..|
0010 03 00 28 00 00 00 00 00-00 00 00 fe 45 e1 3a 7b |..(….. ….E.:{|
0020 2c dd e9 7e f9 3f b4 e5-20 56 36 09 e4 ab 83 a7 |,..~.?.. V6 ….|
0030 bb 00 4d 46 08 03 7d e9-23 b1 d1 |..MF..}. #..|

tls.c:117:in tds_pull_func_login
tls.c:117:in tds_pull_func_login
tls.c:117:in tds_pull_func_login
tls.c:1049:handshake succeeded!!
util.c:333:tdserror(0000007E143EEA20, 00000181DF5FA4D0, 2402, 0)
util.c:363:tdserror: client library returned TDS_INT_CANCEL(2)
util.c:386:tdserror: returning TDS_INT_CANCEL(2)
stream.c:125:Error: tds_convert_stream: tds_iconv returned errno 42, conv_errno 42
stream.c:136:No conversion possible: some bytes left.
login.c:571:login packet rejected
query.c:3757:tds_disconnect()
util.c:179:Changed query state from IDLE to DEAD
util.c:333:tdserror(0000007E143EEA20, 00000181DF5FA4D0, 20002, 0)
util.c:363:tdserror: client library returned TDS_INT_CANCEL(2)
util.c:386:tdserror: returning TDS_INT_CANCEL(2)
dblib.c:8144:dbperror(00000181DD5C5E00, 2402, 0)
dblib.c:8212:dbperror: Calling dblib_err_handler with msgno = 2402; msg->msgtext = «Error converting characters into server’s character set. Some character(s) could not be converted (10.106.5.104)»
dblib.c:8234:dbperror: dblib_err_handler for msgno = 2402; msg->msgtext = «Error converting characters into server’s character set. Some character(s) could not be converted (10.106.5.104)» — returns 2 (INT_CANCEL)
dblib.c:8144:dbperror(00000181DD5C5E00, 20002, 0)
dblib.c:8212:dbperror: Calling dblib_err_handler with msgno = 20002; msg->msgtext = «Adaptive Server connection failed (10.106.5.104)»
dblib.c:8234:dbperror: dblib_err_handler for msgno = 20002; msg->msgtext = «Adaptive Server connection failed (10.106.5.104)» — returns 2 (INT_CANCEL)
util.c:333:tdserror(00000181DD5C1190, 00000181DF5FA4D0, 20002, 0)
dblib.c:8144:dbperror(00000181DD5C5E00, 20002, 0)
dblib.c:8212:dbperror: Calling dblib_err_handler with msgno = 20002; msg->msgtext = «Adaptive Server connection failed (10.106.5.104)»
dblib.c:8234:dbperror: dblib_err_handler for msgno = 20002; msg->msgtext = «Adaptive Server connection failed (10.106.5.104)» — returns 2 (INT_CANCEL)
util.c:363:tdserror: client library returned TDS_INT_CANCEL(2)
util.c:386:tdserror: returning TDS_INT_CANCEL(2)
dblib.c:1282:tdsdbopen: tds_connect_and_login failed for «10.106.5.104»!
dblib.c:1496:dbclose(00000181DD5C5E00)
dblib.c:236:dblib_del_connection(00007FFB9D6472D0, 00000181DF5FA4D0)
mem.c:656:tds_free_all_results()
dblib.c:283:dblib_release_tds_ctx(1)
dblib.c:6066:dbfreebuf(00000181DD5C5E00)
dblib.c:744:dbloginfree(00000181DF623DC0)
Traceback (most recent call last):
File «srcpymssql.pyx», line 636, in pymssql.connect
File «src_mssql.pyx», line 1964, in _mssql.connect
File «src_mssql.pyx», line 682, in _mssql.MSSQLConnection.init
File «src_mssql.pyx», line 1690, in _mssql.maybe_raise_MSSQLDatabaseException
_mssql.MSSQLDatabaseException: (20002, b’DB-Lib error message 20002, severity 9:nAdaptive Server connection failed (10.106.5.104)nDB-Lib error message 20002, severity 9:nAdaptive Server connection failed (10.106.5.104)n’)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File «», line 1, in
File «srcpymssql.pyx», line 642, in pymssql.connect
pymssql.OperationalError: (20002, b’DB-Lib error message 20002, severity 9:nAdaptive Server connection failed (10.106.5.104)nDB-Lib error message 20002, severity 9:nAdaptive Server connection failed (10.106.5.104)n’

I’ve been using this guide for connecting to database through pyodbc: https://github.com/mkleehammer/pyodbc/wiki/Connecting-to-SQL-Server-from-Mac-OSX

My config files look like this, in parallel with the tutorial:
In freetds.conf:

[MYMSSQL]
host = localhost
port = 1433
tds version = 7.3

In odbc.ini:

[MYMSSQL]
Description         = Testing SQLServer
Driver              = FreeTDS
Servername          = MYMSSQL

In odbcinst.ini:

[FreeTDS]
   Description=FreeTDS Driver for Linux & MSSQL
   Driver=/usr/local/lib/libtdsodbc.so
   Setup=/usr/local/lib/libtdsodbc.so
   UsageCount=1

When I test the connection with «tsql -S MYMSSQL -U myuser -P mypassword», I get the error:

Error 20002 (severity 9):
    Adaptive Server connection failed
There was a problem connecting to the server

Likewise, «isql MYMSSQL myuser mypassword» returns an error as well:

[ISQL]ERROR: Could not SQLConnect

EDIT: In the query console:

«SELECT @@SERVERNAME» returns «4a70ffff1294»

«SELECT @@SERVICENAME» returns «MSSQLSERVER»

«SELECT @@VERSION» returns «Microsoft SQL Server 2019 (RTM-CU8) (KB4577194) — 15.0.4073.23 (X64)»

tsql -S MYMSSQL

returns

locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Error 20002 (severity 9):
    Adaptive Server connection failed
There was a problem connecting to the server

The server is running in a docker image. I am able to connect to it via pycharm’s database tool with the 1433 port and the relevant password. Sadly, I’m not very experienced with managing servers. All help is much appreciated.

  • Remove From My Forums
  • Question

  • Ive tried 

    import pyodbc
    conn = pyodbc.connect(‘DSN=<dsn>;UID=<uid>@<host>;PWD=<pwd>’)

    with my credentials but just get an error: 

    pyodbc.Error: (‘IM002’, ‘[IM002] [unixODBC][Driver Manager]Data source name not found, and no d
    efault driver specified (0) (SQLDriverConnect)’)

    or when I try

    TDSVER=8.0 tsql -H XXXXXXXX.database.windows.net -U Username -D DatabaseName -p 1433 -P Password

    I get

    Error 20002 (severity 9):
            Adaptive Server connection failed
    There was a problem connecting to the server

    What’s the easiest/best way to access an SqlAzure database from an azure VM?

Answers

    • Marked as answer by

      Friday, October 31, 2014 11:36 AM

    • Unmarked as answer by
      Mekh Subba
      Friday, October 31, 2014 11:36 AM
    • Proposed as answer by
      Mekh Subba
      Friday, October 31, 2014 11:36 AM
    • Marked as answer by
      Lakshmeesha Phaneesha
      Tuesday, November 4, 2014 6:26 AM

Last Update:2014-07-17
Source: Internet

Author: User

Environment:

Ubuntu12.10 _ x64

Problem:

Use tsql to access SQL Server

>> tsql -H 192.168.88.133 -p 1433 U saError 20002 (severity 9):Adaptive Server connection failed

Solution:

View the TDS version

>> tsql -CCompile-time settings (established with the "configure" script)                            Version: freetds v0.91             freetds.conf directory: /usr/local/freetds/etc     MS db-lib source compatibility: yes        Sybase binary compatibility: no                      Thread safety: yes                      iconv library: yes                        TDS version: 7.1                              iODBC: no                           unixodbc: yes              SSPI "trusted" logins: no                           Kerberos: no

View freetds. conf file

>> vim /usr/local/freetds/etc/freetds.conf

Add the corresponding version information

# A typical Microsoft server[egServer71]        host = ntmachine.domain.com        port = 1433        tds version = 7.1

View data source files

>> vim /etc/tds.datasource.template 

Modify tds_version

TDS_Version          = 7.1

View ODBC. ini file

>> vim /etc/odbc.ini

Modify tds_version

TDS_Version          = 7.1

 

Note:There may be more than one solution to this problem. LZ has not yet figured out the root cause of the problem, but has solved the problem through the above methods. LZ will work harder to find out the cause of the problem and will update it later.

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Error 20002 severity 9 adaptive server connection failed
  • Error 2000 reading sector
  • Error 2000 0150
  • Error 200 что это
  • Error 200 message http error

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии