Unable to connect to MS-SQL with ISQL

First post on StackExchange - please come through :)

I have an ODBC setup in Centos 6 to execute ms-sql queries from my Asterisk installation.

My configuration files:

file / etc / odbc.ini

[asterisk-connector]
Description     = MS SQL connection to 'asterisk' database
Driver          = /usr/lib64/libtdsodbc.so
Setup           = /usr/lib64/libtdsS.so
Servername      = SQL2
Port            = 1433
Username        = MyUsername
Password        = MyPassword
TDS_Version     = 7.0

/etc/odbcinst.ini

[odbc-test]
Description = TDS connection
Driver = /usr/lib64/libtdsodbc.so
Setup = /usr/lib64/libtdsS.so
UsageCount = 1
FileUsage = 1

/etc/asterisk/res_odbc.conf

[asterisk-connector]
enabled => yes
dsn => asterisk-connector
username => MyUsername
password => MyPassword
pooling => no
limit =>
pre-connect => yes

I can connect through ISQL when I pass the password and username:

[root@TestVM etc]# isql -v asterisk-connector MyUsername MyPassword
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL>

.. but I should be able to connect without a username / password. All that returns:

[root@TestVM etc]# isql -v asterisk-connector
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[01000][unixODBC][FreeTDS][SQL Server]Adaptive Server connection failed
[ISQL]ERROR: Could not SQLConnect

As if ISQL could not read the username and password from the configuration files.

I need to be able to execute MS-SQL searches from the Asterisk dialog plan, but for this I should be able to call ISQL only with the name of the data source and cannot pass authentication parameters.

, , ,

isql -v asterisk-connector

.

, .

.

Edit:

. . :

[ODBC][27557][1455205133.129690][SQLConnect.c][3614]
                Entry:
                        Connection = 0xac3080
                        Server Name = [asterisk-connector][length = 18 (SQL_NTS)]
                        User Name = [NULL]
                        Authentication = [NULL]
                UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE 'UCS-2LE'

                DIAG [01000] [FreeTDS][SQL Server]Adaptive Server connection failed

                DIAG [S1000] [FreeTDS][SQL Server]Unable to connect to data source

, [NULL]. , / odbc.ini res_odbc.conf, , . :)

Edit2:

OSQL :

[root@TestVM etc]# osql -S SQL2 -U MyUsername -P MyPassword
checking shared odbc libraries linked to isql for default directories...
strings: '': No such file
        trying /tmp/sqlH ... no
        trying /tmp/sqlL ... no
        trying /etc ... OK
checking odbc.ini files
        reading /root/.odbc.ini
[SQL2] not found in /root/.odbc.ini
        reading /etc/odbc.ini
[SQL2] found in /etc/odbc.ini
found this section:
looking for driver for DSN [SQL2] in /etc/odbc.ini
  no driver mentioned for [SQL2] in odbc.ini
looking for driver for DSN [default] in /etc/odbc.ini
osql: error: no driver found for [SQL2] in odbc.ini
+4
3

, ( ). odbc . Asterisk, res_odbc.ini. , Asterisk, conencts .

, , .

odbc.ini

[asterisk-connector]
Description = MS SQL connection to asterisk database
driver = /usr/lib64/libtdsodbc.so
servername = SQL2
Port = 1433
User = MyUsername
Password = MyPassword

odbcinst.ini

[FreeTDS]
Description = TDS connection
Driver = /usr/lib64/libtdsodbc.so
UsageCount = 1

[ODBC]
trace           = Yes
TraceFile       = /tmp/sql.log
ForceTrace      = Yes

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
# 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
[SQL2]
        host = 192.168.1.59
        port = 1433
        tds version = 8.0

res_odbc.conf

[asterisk-connector]
enabled = yes
dsn = asterisk-connector
username = MyUsername
password = MyPassword
pooling = no
limit = 1
pre-connect = yes

, Centos 64 lib64. ( 64-) .

- :)

0

"Username" " UID" "Password" " PWD" odbc.ini.... FreeTDS - 4 - ODBC:

ODBC odbc.ini. odbc.ini , (DSN). ODBC, , SQLConnect (DSN, UID, PWD), DSN - odbc.ini, UID - PWD. DSN odbc.ini. .

ODBC 3.0 : SQLDriverConnect. , . SQLDriverConnect SQLConnect, - - , DSN, UID PWD - , . , , . , DSN SQLDriverConnect, odbc.ini. DSN, odbc.ini.

0

Nick Gorham unixODBC , , isql /

, ,

, unixODBC - , , , (, , , ).

isql, . ,

$ps -aux

.

? , ? ?

.

:

,

. odbc.ini ~/.odbc.ini, .

isql , ilsq, , , .

0
source

Source: https://habr.com/ru/post/1628330/


All Articles