2016-11-29 1 views
0

J'ai des problèmes pour interroger une base de données MSSQL distante à partir de ma carte linux bras. J'ai compilé unixODBX et FreeTDS, copié tous les fichiers sur le tableau de bras avec le même chemin que sur la machine Ubuntu où ils ont été compilés. J'ai également compilé tout pour la machine Ubuntu. Sur l'ordinateur Ubuntu, je peux me connecter et interroger la base de données avec tsql et isql. Dans le tableau des bras, je peux seulement me connecter et interroger avec tsql, pas avec isql.Je me connecte à la base de données MSSQL avec la carte bras Linux en utilisant les problèmes UnixODBC et FreeTDS

COMPILATION DU CONSEIL D'ADMINISTRATION ARM DANS LA MACHINE UBUNTU:

unixODBX:

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

j'ai enlevé/usr/local/unixodbc-bras/bin/odbc_config sinon je could't compiler.

FreeTDS:

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

j'ai utilisé --disable-libiconv parce que sans cette option ne fonctionnait pas. Puis j'ai copié les fichiers dans les répertoires "bin", "lib" et "etc" sur le tableau des bras avec le même chemin que sur la machine 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 

Les fichiers Configuartion sont les suivants:

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]:/# 

configuration 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]:/# 

configuration 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]:/# 

Courir 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]:/# 

Courir 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]:/# 

Ces comman ds travaillent tous deux dans la machine Ubuntu avec les mêmes fichiers de configuration.

Quelqu'un peut-il aider à ce sujet? Merci beaucoup.

Répondre

0

De la page man isql ...

DSN isql [USER [MOT DE PASSE]] [options]

DSN

. Le nom de la source de données, qui doit être utilisé pour établir la connexion à la base de données. La source de données est recherchée dans les fichiers /etc/odbc.ini et $ HOME/.odbc.ini dans cet ordre, ce dernier écrasant le premier.

Tsql avec -S utilise votre fichier freetds.conf. Mais il semble que vous ayez le fichier odbc.ini dans /usr/local/unixodbc-arm/etc/odbc.ini

+0

Merci beaucoup. Maintenant ça marche. – GrandJonas