# Res\_config\_odbc.c: No database handle available with the name of 'asterisk' (check res\_odbc.conf)

**URL:** <https://community.asterisk.org/t/res-config-odbc-c-no-database-handle-available-with-the-name-of-asterisk-check-res-odbc-conf/66876>\
**Category:** Asterisk Support\
**Created:** [June 2, 2016, 7:16am UTC](https://community.asterisk.org/t/res-config-odbc-c-no-database-handle-available-with-the-name-of-asterisk-check-res-odbc-conf/66876 "2016-06-02T07:16:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![silimms](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@silimms](https://community.asterisk.org/u/silimms)\
**Post date:** [June 2, 2016, 7:16am UTC](https://community.asterisk.org/t/res-config-odbc-c-no-database-handle-available-with-the-name-of-asterisk-check-res-odbc-conf/66876/1 "2016-06-02T07:16:03Z")

</div>

hi, I’m getting this error on my pbx

ERROR[6723] res\_config\_odbc.c: No database handle available with the name of ‘asterisk’ (check res\_odbc.conf)

Asterisk Version - 13.7.2  
OS - Unbuntu Server 14-04(64 Bit)

This is my setting:

root@pbx:~# cat /etc/odbcinst.ini  
[MySQL]  
Description = ODBC for MySQL  
Driver = /usr/lib/x86\_64-linux-gnu/odbc/libmyodbc.so  
Setup = /usr/lib/x86\_64-linux-gnu/odbc/libodbcmyS.so  
FileUsage = 1

root@pbx:~# cat /etc/odbc.ini  
[MYSQL-TravMan4]  
Description = TravMan4 MySQL ODBC  
Driver = /usr/lib/x86\_64-linux-gnu/odbc/libmyodbc.so  
Socket = /var/run/mysqld/mysqld.sock  
Server = localhost  
User = root  
Password= 123456  
Port = 3306  
Database= TravMan4  
Option = 3

[MYSQL-asteridex]  
Description = asteridex MySQL ODBC  
Driver = /usr/lib/x86\_64-linux-gnu/odbc/libmyodbc.so  
Socket = /var/run/mysqld/mysqld.sock  
Server = localhost  
User = root  
Password= 123456  
Port = 3306  
Database= asteridex  
Option = 3

[MYSQL-asterisk]  
Description = asterisk MySQL ODBC  
Driver = /usr/lib/x86\_64-linux-gnu/odbc/libmyodbc.so  
Socket = /var/run/mysqld/mysqld.sock  
Server = localhost  
User = root  
Password= 123456  
Port = 3306  
Database= asterisk  
Option = 3

[MYSQL-asteriskcdrdb]  
Description = asteriskcdrdb MySQL ODBC  
Driver = /usr/lib/x86\_64-linux-gnu/odbc/libmyodbc.so  
Socket = /var/run/mysqld/mysqld.sock  
Server = localhost  
User = root  
Password= 123456  
Port = 3306  
Database= asteriskcdrdb  
Option = 3

[MYSQL-mysql]  
Description = mysql MySQL ODBC  
Driver = /usr/lib/x86\_64-linux-gnu/odbc/libmyodbc.so  
Socket = /var/run/mysqld/mysqld.sock  
Server = localhost  
User = root  
Password= 123456  
Port = 3306  
Database= mysql  
Option = 3

[MYSQL-performance\_schema]  
Description = performance\_schema MySQL ODBC  
Driver = /usr/lib/x86\_64-linux-gnu/odbc/libmyodbc.so  
Socket = /var/run/mysqld/mysqld.sock  
Server = localhost  
User = root  
Password= 123456  
Port = 3306  
Database= performance\_schema  
Option = 3

[MYSQL-timeclock]  
Description = timeclock MySQL ODBC  
Driver = /usr/lib/x86\_64-linux-gnu/odbc/libmyodbc.so  
Socket = /var/run/mysqld/mysqld.sock  
Server = localhost  
User = root  
Password= 123456  
Port = 3306  
Database= timeclock  
Option = 3

[MYSQL-zipcodes]  
Description = zipcodes MySQL ODBC  
Driver = /usr/lib/x86\_64-linux-gnu/odbc/libmyodbc.so  
Socket = /var/run/mysqld/mysqld.sock  
Server = localhost  
User = root  
Password= 123456  
Port = 3306  
Database= zipcodes  
Option = 3

root@pbx:~# cat /etc/asterisk/res\_odbc.conf  
;--------------------------------------------------------------------------------;  
; Do NOT edit this file as it is auto-generated by FreePBX. All modifications to ;  
; this file must be done via the web gui. There are alternative files to make ;  
; custom modifications, details at: [http://freepbx.org/configuration\_files](http://freepbx.org/configuration_files) ;  
;--------------------------------------------------------------------------------;  
;  
; This file is part of FreePBX.  
;  
; FreePBX is free software: you can redistribute it and/or modify  
; it under the terms of the GNU General Public License as published by  
; the Free Software Foundation, either version 2 of the License, or  
; (at your option) any later version.  
;  
; FreePBX is distributed in the hope that it will be useful,  
; but WITHOUT ANY WARRANTY; without even the implied warranty of  
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
; GNU General Public License for more details.  
;  
; You should have received a copy of the GNU General Public License  
; along with FreePBX. If not, see [http://www.gnu.org/licenses/](http://www.gnu.org/licenses/).  
;  
; Copyright © 2012 Astrogen LLC (USA)

#include res\_odbc\_custom.conf  
#include res\_odbc\_additional.conf

root@pbx:~# cat /etc/asterisk/res\_odbc\_custom.conf  
[MySQL-TravMan4]  
enabled =\> yes  
dsn =\> MySQL-TravMan4  
username =\> root  
password =\> 123456  
preconnect =\> yes

[MySQL-asteridex]  
enabled =\> yes  
dsn =\> MySQL-asteridex  
username =\> root  
password =\> 123456  
preconnect =\> yes

[MySQL-asterisk]  
enabled =\> yes  
dsn =\> MySQL-asterisk  
username =\> root  
password =\> 123456  
preconnect =\> yes

[MySQL-asteriskcdrdb]  
enabled =\> yes  
dsn =\> MySQL-asteriskcdrdb  
username =\> root  
password =\> 123456  
preconnect =\> yes

[MySQL-mysql]  
enabled =\> yes  
dsn =\> MySQL-mysql  
username =\> root  
password =\> 123456  
preconnect =\> yes

[MySQL-performance\_schema]  
enabled =\> yes  
dsn =\> MySQL-performance\_schema  
username =\> root  
password =\> 123456  
preconnect =\> yes

[MySQL-timeclock]  
enabled =\> yes  
dsn =\> MySQL-timeclock  
username =\> root  
password =\> 123456  
preconnect =\> yes

[MySQL-zipcodes]  
enabled =\> yes  
dsn =\> MySQL-zipcodes  
username =\> root  
password =\> 123456  
preconnect =\> yes

root@pbx:~# cat /etc/asterisk/res\_odbc\_additional.conf  
;--------------------------------------------------------------------------------;  
; Do NOT edit this file as it is auto-generated by FreePBX. ;  
;--------------------------------------------------------------------------------;  
; For information on adding additional paramaters to this file, please visit the ;  
; [FreePBX.org](http://FreePBX.org) wiki page, or ask on IRC. This file was created by the new FreePBX ;  
; BMO - Big Module Object. Any similarity in naming with BMO from Adventure Time ;  
; is totally deliberate. ;  
;--------------------------------------------------------------------------------;  
[asteriskcdrdb]  
enabled=\>yes  
dsn=\>MySQL-asteriskcdrdb  
pooling=\>no  
limit=\>1  
pre-connect=\>yes  
username=\>asteriskuser  
password=\>123456

---

<div class="post-metadata">

**Author:** ![silimms](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@silimms](https://community.asterisk.org/u/silimms)\
**Post date:** [June 2, 2016, 7:17am UTC](https://community.asterisk.org/t/res-config-odbc-c-no-database-handle-available-with-the-name-of-asterisk-check-res-odbc-conf/66876/2 "2016-06-02T07:17:55Z")

</div>

root@pbx:~# cat /etc/asterisk/extconfig.conf

;  
; Static and realtime external configuration  
; engine configuration  
;  
; See [https://wiki.asterisk.org/wiki/display/AST/Realtime+Database+Configuration](https://wiki.asterisk.org/wiki/display/AST/Realtime+Database+Configuration)  
; for basic table formatting information.  
;  
[settings]  
;  
; Static configuration files:  
;  
; file.conf =\> driver,database[,table[,priority]]  
;  
; maps a particular configuration file to the given  
; database driver, database and table (or uses the  
; name of the file as the table if not specified)  
;  
; Uncomment to load queues.conf via the odbc engine.  
;  
;queues.conf =\> odbc,asterisk,ast\_config  
;extensions.conf =\> sqlite,asterisk,ast\_config  
;  
; The following files CANNOT be loaded from Realtime storage:  
; asterisk.conf  
; extconfig.conf (this file)  
; logger.conf  
;  
; Additionally, the following files cannot be loaded from  
; Realtime storage unless the storage driver is loaded  
; early using ‘preload’ statements in modules.conf:  
; manager.conf  
; cdr.conf  
; rtp.conf  
;  
; Named ACLs specified in realtime also can not be used  
; from manager.conf unless the storage driver is preloaded.  
; Attempting to use a realtime stored named ACL before the  
; driver is loaded will result in an invalid ACL which  
; rejects all addresses.  
;  
; Realtime configuration engine  
;  
; maps a particular family of realtime  
; configuration to a given database driver,  
; database and table (or uses the name of  
; the family if the table is not specified  
;  
;example =\> odbc,asterisk,alttable,1  
;example =\> mysql,asterisk,alttable,2  
;example2 =\> ldap,“dc=oxymium,dc=net”,example2  
;  
; Additionally, priorities are now supported for use as failover methods  
; for retrieving realtime data. If one connection fails to retrieve any  
; information, the next sequential priority will be tried next. This  
; especially works well with ODBC connections, since res\_odbc now caches  
; when connection failures occur and prevents immediately retrying those  
; connections until after a specified timeout. Note: priorities must  
; start at 1 and be sequential (i.e. if you have only priorities 1, 2,  
; and 4, then 4 will be ignored, because there is no 3).  
;  
;  
; Possible driver backends:  
;  
; “odbc” is shown in the examples below, but is not the only valid realtime  
; engine. Here are several of the possible options:  
; odbc … res\_config\_odbc  
; sqlite … res\_config\_sqlite  
; sqlite3 … res\_config\_sqlite3  
; pgsql … res\_config\_pgsql  
; curl … res\_config\_curl  
; ldap … res\_config\_ldap  
; mysql … res\_config\_mysql (available via add-ons in menuselect)  
;  
; Note: The res\_config\_pgsql and res\_config\_sqlite backends configure the  
; database used in their respective configuration files and ignore the  
; database name configured in this file.  
;  
;iaxusers =\> odbc,asterisk  
;iaxpeers =\> odbc,asterisk  
;sippeers =\> odbc,asterisk  
;sipregs =\> odbc,asterisk ; (avoid sipregs if possible, e.g. by using a view)  
;ps\_endpoints =\> odbc,asterisk  
ps\_endpoints =\> odbc,asterisk,pbx\_endpoint\_id\_ips  
;ps\_auths =\> odbc,asterisk  
;ps\_aors =\> odbc,asterisk  
;ps\_domain\_aliases =\> odbc,asterisk  
;ps\_endpoint\_id\_ips =\> odbc,asterisk  
;voicemail =\> odbc,asterisk  
;extensions =\> odbc,asterisk  
;meetme =\> mysql,general  
;queues =\> odbc,asterisk  
;queue\_members =\> odbc,asterisk  
;queue\_rules =\> odbc,asterisk  
;acls =\> odbc,asterisk  
;musiconhold =\> mysql,general  
;queue\_log =\> mysql,general  
;  
;  
; While most dynamic realtime engines are automatically used when defined in  
; this file, ‘extensions’, distinctively, is not. To activate dynamic realtime  
; extensions, you must turn them on in each respective context within  
; extensions.conf with a switch statement. The syntax is:  
; switch =\> Realtime/[[db\_context@]tablename]/  
; The only option available currently is the ‘p’ option, which disallows  
; extension pattern queries to the database. If you have no patterns defined  
; in a particular context, this will save quite a bit of CPU time. However,  
; note that using dynamic realtime extensions is not recommended anymore as a  
; best practice; instead, you should consider writing a static dialplan with  
; proper data abstraction via a tool like func\_odbc.

root@pbx:~# cat /etc/asterisk/modules.conf  
;--------------------------------------------------------------------------------;  
; Do NOT edit this file as it is auto-generated by FreePBX. ;  
;--------------------------------------------------------------------------------;  
; For information on adding additional paramaters to this file, please visit the ;  
; [FreePBX.org](http://FreePBX.org) wiki page, or ask on IRC. This file was created by the new FreePBX ;  
; BMO - Big Module Object. Any similarity in naming with BMO from Adventure Time ;  
; is totally deliberate. ;  
;--------------------------------------------------------------------------------;

[modules]  
autoload=yes  
preload = pbx\_config.so  
preload = chan\_local.so  
noload = chan\_woomera.so  
noload = pbx\_gtkconsole.so  
noload = pbx\_kdeconsole.so  
noload = app\_intercom.so  
noload = chan\_modem.so  
noload = chan\_modem\_bestdata.so  
noload = chan\_modem\_i4l.so  
noload = app\_trunkisavail.so  
noload = chan\_alsa.so  
noload = chan\_oss.so  
noload = app\_directory\_odbcstorage.so  
noload = app\_voicemail\_odbcstorage.so  
noload = chan\_modem\_aopen.so  
noload = chan\_woomera.so  
noload = cdr\_radius.so  
noload = cel\_radius.so  
load = format\_wav.so  
load = format\_pcm.so  
load = format\_mp3.so  
load = res\_musiconhold.so

and I have try to do odbc debugging

root@pbx:/etc/asterisk# isql MySQL-asterisk root 123456  
±--------------------------------------+  
| Connected! |  
| |  
| sql-statement |  
| help [tablename] |  
| quit |  
| |  
±--------------------------------------+  
SQL\>

## ODBC DSN Settings

Name: MySQL-TravMan4  
DSN: MySQL-TravMan4  
Last connection attempt: 1970-01-01 08:00:00

Name: MySQL-asteridex  
DSN: MySQL-asteridex  
Last connection attempt: 1970-01-01 08:00:00

Name: MySQL-asterisk  
DSN: MySQL-asterisk  
Last connection attempt: 1970-01-01 08:00:00

Name: MySQL-asteriskcdrdb  
DSN: MySQL-asteriskcdrdb  
Last connection attempt: 1970-01-01 08:00:00

Name: MySQL-mysql  
DSN: MySQL-mysql  
Last connection attempt: 1970-01-01 08:00:00

Name: MySQL-performance\_schema  
DSN: MySQL-performance\_schema  
Last connection attempt: 1970-01-01 08:00:00

Name: MySQL-timeclock  
DSN: MySQL-timeclock  
Last connection attempt: 1970-01-01 08:00:00

Name: MySQL-zipcodes  
DSN: MySQL-zipcodes  
Last connection attempt: 1970-01-01 08:00:00

Name: asteriskcdrdb  
DSN: MySQL-asteriskcdrdb  
Last connection attempt: 2016-06-02 14:44:42

anyone know how to solve this problem?  
thanks in advance for your help.

---

<div class="post-metadata">

**Author:** ![astbox](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/astbox/32/1691_2.png) [@astbox](https://community.asterisk.org/u/astbox)\
**Post date:** [June 2, 2016, 3:52pm UTC](https://community.asterisk.org/t/res-config-odbc-c-no-database-handle-available-with-the-name-of-asterisk-check-res-odbc-conf/66876/3 "2016-06-02T15:52:22Z")

</div>

Change in the res\_odbc\_custom.conf from

[MySQL-asterisk]

to

[asterisk]

and try again.

---

<div class="post-metadata">

**Author:** ![silimms](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@silimms](https://community.asterisk.org/u/silimms)\
**Post date:** [June 3, 2016, 1:49am UTC](https://community.asterisk.org/t/res-config-odbc-c-no-database-handle-available-with-the-name-of-asterisk-check-res-odbc-conf/66876/4 "2016-06-03T01:49:09Z")

</div>

the error change to show this

[2016-06-03 09:48:12] WARNING[3232] res\_odbc.c: SQL Execute error -1! Verifying connection to asterisk [MySQL-asterisk]…  
[2016-06-03 09:48:12] WARNING[3232] res\_odbc.c: Connection is down attempting to reconnect…  
[2016-06-03 09:48:12] NOTICE[3232] res\_odbc.c: Connecting asterisk  
[2016-06-03 09:48:12] NOTICE[3232] res\_odbc.c: res\_odbc: Connected to asterisk [MySQL-asterisk]  
[2016-06-03 09:48:12] WARNING[3232] res\_odbc.c: SQL Execute returned an error -1: 42S02: [MySQL][ODBC 5.1 Driver][mysqld-5.5.49-0ubuntu0.14.04.1]Table ‘asterisk.pbx\_endpoint\_id\_ips’ doesn’t  
exist (106)  
[2016-06-03 09:48:12] WARNING[3232] res\_odbc.c: SQL Execute error -1! Verifying connection to asterisk [MySQL-asterisk]…  
[2016-06-03 09:48:12] WARNING[3232] res\_odbc.c: Connection is down attempting to reconnect…  
[2016-06-03 09:48:12] NOTICE[3232] res\_odbc.c: Connecting asterisk  
[2016-06-03 09:48:12] NOTICE[3232] res\_odbc.c: res\_odbc: Connected to asterisk [MySQL-asterisk]

---

<div class="post-metadata">

**Author:** ![jcolp](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/jcolp/32/8848_2.png) [@jcolp](https://community.asterisk.org/u/jcolp)\
**Post date:** [June 3, 2016, 10:18am UTC](https://community.asterisk.org/t/res-config-odbc-c-no-database-handle-available-with-the-name-of-asterisk-check-res-odbc-conf/66876/5 "2016-06-03T10:18:21Z")

</div>

The warning is pretty clear - the table doesn’t exist that you are trying to use. Did you create it[1]?

[1] [https://wiki.asterisk.org/wiki/display/AST/Setting+up+PJSIP+Realtime](https://wiki.asterisk.org/wiki/display/AST/Setting+up+PJSIP+Realtime)
