2016-11-29 128 views
0

我有問題從我的arm linux板上查詢遠程MSSQL數據庫。 我編譯了unixODBX和FreeTDS,把所有的文件都複製到arm板上,路徑和Ubuntu機器中的路徑相同,在那裏它們被編譯。 我也編譯了Ubuntu機器的所有東西。 在Ubuntu機器上,我可以用tsql和isql連接和查詢數據庫。 在arm板上,我只能使用tsql連接和查詢,而不能使用isql。使用unixODBC和FreeTDS問題連接到使用arm linux板的MSSQL數據庫

編制在Ubuntu機ARM板:

unixODBX:

./configure --prefix=/usr/local/unixodbc-arm --host=arm-linux 
make 
make install 

我刪除的/ usr /本地/ unixODBC的臂/斌/ odbc_config否則我便無法對其進行編譯。

freetds的:

./configure --prefix=/usr/local/freetds-arm --with-unixodbc=/usr/local/unixodbc-arm --host=arm-linux --disable-libiconv 
make 
make all 

我用--disable-libiconv的,因爲如果沒有這個選項是行不通的。

比我複製「bin」,「lib」和「etc」目錄中的文件到Ubuntu機器上的路徑相同。

/usr/local/unixodbc-arm/bin 
/usr/local/unixodbc-arm/lib 
/usr/local/unixodbc-arm/etc 

/usr/local/freetds-arm/bin 
/usr/local/freetds-arm/lib 
/usr/local/freetds-arm/etc 

的configuartion文件如下:

freetds.conf:

[email protected]:/# cat /usr/local/freetds-arm/etc/freetds.conf 
# $Id: freetds.conf,v 1.12 2007-12-25 06:02:36 jklowden Exp $ 
# 
# This file is installed by FreeTDS if no file by the same on a multi-user system 
# name is found in the installation directory. 
# 
# For information about the layout of this file and its settings, 
# see the freetds.conf manpage "man freetds.conf". 

# Global settings are overridden by those in a database 
# server specific section 
[global] 
     # TDS protocol version 
;  tds version = 4.2 

     # Whether to write a TDSDUMP file for diagnostic purposes 
     # (setting this to /tmp is insecure on a multi-user system) 
;  dump file = /tmp/freetds.log 
;  debug flags = 0xffff 

     # Command and connection timeouts 
;  timeout = 10 
;  connect timeout = 10 

     # If you get out-of-memory errors, it may mean that your client 
     # is trying to allocate a huge buffer for a TEXT field. 
     # Try setting 'text size' to a more reasonable limit 
     text size = 64512 

# A typical Sybase server 
[egServer50] 
     host = symachine.domain.com 
     port = 5000 
     tds version = 5.0 

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

# Microsoft SQL Server 
[SQLEXPRESS] 
     host = 192.168.0.195 
     port = 1433 
     tds version = 7.0 
     client charset = UTF-8 
[email protected]:/# 

ODBCINST.INI:

[email protected]:/# cat /usr/local/unixodbc-arm/etc/odbcinst.ini 
[FreeTDS] 
Description=TDS driver (Sybade/MS SQL) 
Driver=/usr/local/freetds-arm/lib/libtdsodbc.so 
UsageCount=2 

[email protected]:/# 

ODBC.INI

[email protected]:/# cat /usr/local/unixodbc-arm/etc/odbc.ini 
[SQLEXPRESS] 
Description   = Test to FreeTDS 
Driver    = FreeTDS 
Trace    = Yes 
TraceFile   = sql.log 
Database   = gti 
Servername   = SQLEXPRESS 
UserName   = gti_monitor 
Password   = gti_monitor 
Port    = 1433 
ReadOnly   = No 
RowVersioning  = No 
ShowSystemTables = No 
ShowOidColumn  = No 
FakeOidIndex  = No 
ConnSettings  = 
[email protected]:/# 

TSQL配置:

[email protected]:/# tsql -C 
Compile-time settings (established with the "configure" script) 
          Version: freetds vdev.0.99.134 
      freetds.conf directory: /usr/local/freetds-arm/etc 
    MS db-lib source compatibility: no 
     Sybase binary compatibility: no 
         Thread safety: yes 
         iconv library: no 
         TDS version: 5.0 
           iODBC: no 
          unixodbc: yes 
       SSPI "trusted" logins: no 
          Kerberos: no 
          OpenSSL: no 
          GnuTLS: no 
[email protected]:/# 

ODBCINST配置:

[email protected]:/# odbcinst -j 
unixODBC 2.3.4 
DRIVERS............: /usr/local/unixodbc-arm/etc/odbcinst.ini 
SYSTEM DATA SOURCES: /usr/local/unixodbc-arm/etc/odbc.ini 
FILE DATA SOURCES..: /usr/local/unixodbc-arm/etc/ODBCDataSources 
USER DATA SOURCES..: /home/root/.odbc.ini 
SQLULEN Size.......: 4 
SQLLEN Size........: 4 
SQLSETPOSIROW Size.: 2 
[email protected]:/# 

運行TSQL:

[email protected]:/# tsql -S SQLEXPRESS -U gti_monitor -P gti_monitor 
locale is "C" 
locale charset is "ANSI_X3.4-1968" 
using default charset "UTF-8" 
1> select * from pressures 
2> go 
id  datetime  press1 press2 
NULL NULL 1  2 
(1 row affected) 
1> quit 
[email protected]:/# 

運行ISQL:

[email protected]:/# isql SQLEXPRESS gti_monitor gti_monitor -v 
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source 
[ISQL]ERROR: Could not SQLConnect 
[email protected]:/# 

這些comman ds都在Ubuntu機器上使用相同的配置文件。

任何人都可以幫忙嗎? 非常感謝。

回答

0

從ISQL手冊頁...

ISQL DSN [USER [密碼] [選項]

DSN。數據源名稱,應該用於連接數據庫。按照該順序在/etc/odbc.ini和$ HOME/.odbc.ini文件中查找數據源,後者覆蓋前者。

帶有-S的Tsql正在使用您的freetds.conf文件。但它看起來像/usr/local/unixodbc-arm/etc/odbc.ini中的odbc.ini文件

+0

非常感謝。現在它正在工作。 – GrandJonas

相關問題