My Rails 4.2.1應用必須連接到Microsoft SQL 2008 R2數據庫。我正在使用tiny_tds
寶石版本1.0.4。 FreeTDS v1.00.15安裝在運行Ubuntu 14.04的生產服務器上。從Rails應用連接到Windows SQL Server 2008 R2
我在每個循環內運行查詢,並且無法完成循環,進程在完成之前崩潰。 我試着玩tiny_tds選項沒有成功。
下面是我使用來獲取tiny_tds客戶端的代碼(檢查tds_version
和timeout
選項):
client = TinyTds::Client.new(username: db_conf['username'], password: db_conf['password'], host: db_conf['host'], port: db_conf['port'], database: db_conf['database'], tds_version: '7.3', timeout: 15000, appname: 'ERP')
這裏的freetds的日誌這樣的錯誤發生之後。
packet.c:741:Sending packet 0000 12 01 00 ce 00 00 00 00-16 03 01 00 86 10 00 00 |........ ........| 0010 82 00 80 6e d9 e2 dc 97-9d 77 59 9a 5b da e3 e2 |...n.... .wY.[...| 0020 8b aa 66 ed ec 5e e2 02-e5 6c fd db e1 ef 47 1a |..f..^.. .l....G.| 0030 9d 63 03 ed 6d 3e 28 3b-b9 64 fd 92 71 34 ff ba |.c..m>(; .d..q4..| 0040 7d 3c 8d ee 7b 34 75 e9-d5 b7 c6 83 a9 7d e6 7f |}<..{4u. .....}..| 0050 71 7e 25 11 82 b8 76 b1-c6 ba 86 b4 c3 0a 47 f0 |q~%...v. ......G.| 0060 51 96 c7 e2 5f ca 07 b2-95 53 b9 9e bb 2c e7 cb |Q..._... .S...,..| 0070 be 0a b5 eb b0 f3 41 1d-cd 86 fc a6 53 08 5e 56 |......A. ....S.^V| 0080 29 85 79 14 dc 2b 74 7b-b2 43 2c e8 0e 87 60 e4 |).y..+t{ .C,...
.| 0090 10 ef f8 14 03 01 00 01-01 16 03 01 00 30 c7 f0 |........ .....0..| 00a0 35 f5 2c 6e 79 8d 85 b9-bd 60 b7 09 8c 7e 29 18 |5.,ny... .
...~).| 00b0 4a 56 ea c3 4e 13 bf e3-c5 8d f6 68 31 31 54 ee |JV..N... ...h11T.| 00c0 bf 2f 75 8d e9 9e c0 a9-d0 d2 9e 5b c9 92 |./u..... ...[..|tls.c:105:in tds_pull_func_login query.c:3796:tds_disconnect() util.c:165:Changed query state from IDLE to DEAD util.c:322:tdserror(0x80b75e0, 0xa04ca80, 20017, 0) dblib.c:7947:dbperror(0xae62780, 20017, 0) dblib.c:8015:dbperror: Calling dblib_err_handler with msgno = 20017; msg->msgtext = "Unexpected EOF from the server (192.168.32.105:1433)" dblib.c:5777:dbgetuserdata(0xae62780) dblib.c:8037:dbperror: dblib_err_handler for msgno = 20017; msg->msgtext = "Unexpected EOF from the server (192.168.32.105:1433)" -- returns 2 (INT_CANCEL) util.c:352:tdserror: client library returned TDS_INT_CANCEL(2) util.c:375:tdserror: returning TDS_INT_CANCEL(2) util.c:375:tdserror: returning TDS_INT_CANCEL(2) tls.c:942:handshake failed login.c:530:login packet rejected util.c:322:tdserror(0x80b75e0, 0xa04ca80, 20002, 0) dblib.c:7947:dbperror(0xae62780, 20002, 0) dblib.c:8015:dbperror: Calling dblib_err_handler with msgno = 20002; msg->msgtext = "Adaptive Server connection failed"
而這裏的tsql -C
輸出:
~$ tsql -C
Compile-time settings (established with the "configure" script)
Version: freetds v1.00.15
freetds.conf directory: /usr/local/etc
MS db-lib source compatibility: no
Sybase binary compatibility: no
Thread safety: yes
iconv library: yes
TDS version: auto
iODBC: no
unixodbc: no
SSPI "trusted" logins: no
Kerberos: no
OpenSSL: yes
GnuTLS: no
MARS: no
任何想法,我應該做些什麼來解決這些Unexpected EOF from the server
錯誤?
安裝什麼版本的freetds的嗎?你應該可以運行'tsql -C'來查看。如果你使用0.91,你需要使用'tds_version:'7.2''; 7.3要求0.95或更高。 – FlipperPA
@FlipperPA看來我正在使用FreeTDS 0.91(從Ubuntu數據包管理器安裝)。使用'tds_version:'7.2'',我得到了與服務器錯誤相同的'意外的EOF'。 –
使用'tds_version:'7.2''會讓你頭痛不已(特別是如果你處理Unicode的話),如果你使用的是0.91。但回到手頭的問題:你可以連接'tsql'嗎?例如,'TDSVER = 7.2 tsql -H 192.168.32.105 -p 1433 -U your_username'?如果這不起作用,你可以telnet 192.168.32.105 1433'並連接?另外,如果您的密碼中包含非字母字符,則可能需要嘗試使用少於20個字符的簡短(ish)字母數字密碼。老版本的FreeTDS在用戶名和密碼上的最大尺寸爲25字符(但我認爲它們增加了0.91)。 – FlipperPA