[Solved] ODBC Set up in Ubuntu, not working in Asterisk

/etc/odbcinst.ini:

[MySQL]
Description=ODBC for MySQL
Driver=/usr/lib/x86_64-linux-gnu/odbc/libmyodbc5a.so
Setup=/usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so
FileUsage=1

[ODBC Driver 17 for SQL Server]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.2.so.0.1
UsageCount=1

/etc/odbc.ini:

[CISNG-connector]
Description=MS SQL Connection to CISNG SQL server
Driver=ODBC Driver 17 for SQL Server
Database=XXXX
Server=XXXXXXXXXXXXXXXXXXX
Encrypt=yes
TrustServerCertificate=yes

[mysql-connector]
Description=MySQL connection for Asterisk
Driver=MySQL
Database=texting
Server=localhost
Port=3306
Socket=/var/lib/mysql/mysql.sock

/etc/asterisk/res_odbc.conf:

[ENV]

ODBCSYSINI => /etc
ODBCINI => /ect/odbc.ini

[CISNG]
enabled => yes
dsn => CISNG-connector
username => xxxxxx
password => xxxxxx
pre-connect => yes
;

I’m able to connect w/ isql via command line without issue. I get the following error in Asterisk when attempting the same:

[2018-08-27 14:42:23] WARNING[11539]: res_odbc.c:957 odbc_obj_connect: res_odbc: Error SQLConnect=-1 errno=0 [unixODBC][Driver Manager]Data source name not found, and no default driver specified
[2018-08-27 14:42:23] NOTICE[11539]: res_odbc.c:616 load_odbc_config: Registered ODBC class ‘CISNG’ dsn->[CISNG-connector]

I’m out of ideas.

I’ve never seen spaces used in the driver name like you have, I would recommend shortening the driver name to just something like ‘SQLServer’ and see if that helps.

Figured this out. The user Asterisk was running as did not have read access to /etc/odbc*.

1 Like