Search code examples
sql-serverubuntuodbcfreetdsunixodbc

FreeTDS not respecting freetds.conf and odbc.ini


I have a problem, FreeTDS keep connecting using version 4.2 even if I set to 8.0 in these settings

I CAN connect using tsql, and when I use tsql it show me it is using 7.1 (alias from 8.0), but my apache2 application keep using 4.2

Where can it be getting this config???

I am using ubuntu

freetds.log

23:50:06.011112 2632 (log.c:196):Starting log file for FreeTDS 0.91
    on 2015-08-19 23:50:06 with debug flags 0xffff.
23:50:06.011141 2632 (iconv.c:330):tds_iconv_open(0x7faab3a4fdb0, ISO-8859-1)
23:50:06.011147 2632 (iconv.c:349):setting up conversions for client charset "ISO-8859-1"
23:50:06.011151 2632 (iconv.c:351):preparing iconv for "ISO-8859-1" <-> "UCS-2LE" conversion
23:50:06.011162 2632 (iconv.c:391):preparing iconv for "ISO-8859-1" <-> "ISO-8859-1" conversion
23:50:06.011166 2632 (iconv.c:394):tds_iconv_open: done
23:50:06.011171 2632 (net.c:205):Connecting to 172.16.12.128 port 1433 (TDS version 4.2)
23:50:06.011200 2632 (net.c:270):tds_open_socket: connect(2) returned "Operation now in progress"
23:50:06.011210 2632 (net.c:306):getsockopt(2) reported: Connection refused
23:50:06.011218 2632 (net.c:316):tds_open_socket() failed
23:50:06.011223 2632 (util.c:331):tdserror(0x7faab38cc290, 0x7faab3a4fdb0, 20009, 111)
23:50:06.011230 2632 (dblib.c:7929):dbperror(0x7faab3998050, 20009, 111)
23:50:06.011235 2632 (dblib.c:7981):20009: "Unable to connect: Adaptive Server is unavailable or does not exist"
23:50:06.011239 2632 (dblib.c:5780):dbgetuserdata(0x7faab3998050)
23:50:06.011244 2632 (dblib.c:8002):"Unable to connect: Adaptive Server is unavailable or does not exist", client returns 2 (INT_CANCEL)
23:50:06.011248 2632 (util.c:361):tdserror: client library returned TDS_INT_CANCEL(2)
23:50:06.011252 2632 (util.c:384):tdserror: returning TDS_INT_CANCEL(2)
23:50:06.011257 2632 (dblib.c:1443):dbclose(0x7faab3998050)
23:50:06.011260 2632 (dblib.c:258):dblib_del_connection(0x7faaa1741840, 0x7faab3a4fdb0)
23:50:06.011294 2632 (mem.c:615):tds_free_all_results()
23:50:06.011304 2632 (dblib.c:305):dblib_release_tds_ctx(1)
23:50:06.011309 2632 (dblib.c:5882):dbfreebuf(0x7faab3998050)
23:50:06.089866 2632 (dblib.c:739):dbloginfree(0x7faab3a4dfc0)

odbc.ini

[OurSoundMainDB]
Driver       = FreeTDS
Description  = ODBC connection via FreeTDS
Trace        = No
Servername   = oursounddb
Database     = OurSoundMainDB
TDS_Version  = 8.0

freetds.conf

[global]
    # TDS protocol version
;       tds version = 7.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 Microsoft server
[oursounddb]
    host = ****************
    port = 1433
    #tds version = 7.2
    tds version = 8.0
    client charset = UTF-8

Solution

  • Resolved!!!

    I inserted the following line in

    "/etc/apache2/envvars"

    export TDSVER=8.0