realtime_odbc: No database handle available with the name of

Hi,

When I am trying to establish the connection with MySQL through UNIX ODBC, I am getting the below error:

ERROR[1413]: res_config_odbc.c:202 realtime_odbc: No database handle available with the name of ‘mydatabase’ (check res_odbc.conf)

I tried to find out the solution and searched many threads in internet. But, could not able to find the solution. Please find my below configuration:

Asterisk Version - 11.10
OS - Ubuntu Server 14.04 (64-Bit)

  1. Installed MySQL client, server, development, unixodbc-dev, and libmyodbc libraries

  2. Content in /etc/odbcinst.ini:
    [MySQL]
    Description = MySQL driver
    Driver = libmyodbc.so
    Setup = libodbcmyS.so
    CPTimeout =
    CPReuse =
    UsageCount = 1

  3. Content in /etc/odbc.ini:
    [MySQL-asterisk]
    Description = MySQL Asterisk database
    Trace = Off
    TraceFile = stderr
    Driver = MySQL
    SERVER = 10.0.0.253
    USER = dbuser
    PASSWORD = dbpassword
    PORT = 3336
    DATABASE = mydatabase

  4. Content in /etc/asterisk/res_odbc.conf:
    [asterisk]
    enabled => yes
    dsn => MySQL-asterisk
    username => dbuser
    password => dbpassword
    pre-connect => yes

  5. Content in /etc/asterisk/extconfig.conf:
    [settings]
    sipusers => odbc,mydatabase,sipuserstable
    sippeers => odbc,mydatabase,sipuserstable
    sipregs => odbc,mydatabase,sipregistrationstable
    voicemail => odbc,mydatabase,sipvoicemailtable

  6. Enable below things in modules.conf:
    autoload=yes
    preload => res_odbc.so
    preload => res_config_odbc.so

I am able to connect to the database manually. But, when I am trying to register from soft phone, it is showing the above error in Asterisk console.

Any help would be appreciated. Thanks in advance.

First of all: Pls use Code-Tags for any configuration parts - this makes a post much better readable.

Second: Your problem is a mismatch between /etc/asterisk/res_odbc.conf and /etc/asterisk/extconfig.conf (and Asterism is telling You exactly this in the error-message):

If You define a ressource as [asterisk] You cannot refer to it as “mydatabase”. The reference needs to match the ressource and it will work.

PS: Probably only a typo, but usualy MySQL would listen on port 3306 instead of the 3336 given here for /etc/odbc.ini.

Thank you for your reply.

“If You define a ressource as [asterisk] You cannot refer to it as “mydatabase”. The reference needs to match the ressource and it will work.”

I made a mistake here and the issue is resolved :smile: