0
votes

I am having problems to query a remote MSSQL database from my arm linux board. I compiled unixODBX and FreeTDS, copied all files to the arm board with the same path as in the Ubuntu machine where they where compiled. I also compiled everything for the Ubuntu machine. In the Ubuntu machine I can connect and query the database with tsql and isql. In the arm board I can only connect and query with tsql, not with isql.

COMPILATION FOR THE ARM BOARD IN THE UBUNTU MACHINE:

unixODBX:

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

I removed /usr/local/unixodbc-arm/bin/odbc_config otherwise I could“t compile it.

FreeTDS:

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

I used --disable-libiconv because without this option was not working.

Than I copied the files in the "bin", "lib" and "etc" directories to the arm board with the same path as in the Ubuntu machine.

/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

The configuartion files are as follows:

freetds.conf:

root@ok335x:/# 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
root@ok335x:/#

odbcinst.ini:

root@ok335x:/# 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

root@ok335x:/#

odbc.ini

root@ok335x:/# 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        =
root@ok335x:/#

tsql configuration:

root@ok335x:/# 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
root@ok335x:/#

odbcinst configuration:

root@ok335x:/# 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
root@ok335x:/#

Running tsql:

root@ok335x:/# 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
root@ok335x:/#

Running isql:

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

These commands are both working in the Ubuntu machine with the same configuration files.

Can anyone help on that? Thank you very much.

1

1 Answers

0
votes

From the isql man page...

isql DSN [USER [PASSWORD]] [options]

DSN. The Data Source Name, which should be used to make connection to the database. The data source is looked for in the /etc/odbc.ini and $HOME/.odbc.ini files in that order, with the latter overwriting the former.

Tsql with -S is using your freetds.conf file. But it looks like you have the odbc.ini file in /usr/local/unixodbc-arm/etc/odbc.ini