ODBC App unable to execute query [solved]

Hello everybody,

I would be really thankful for some help here! I’m still quite new with Asterisk and having trouble getting the odbc app to work. The operating system is a Ubuntu 11.10 server, and the Asterisk version is 1.8.

When I try to execute a query, I get the following error:

Another thing that’s wrong is that Asterisk is not showing a database connection:

[code]vsrv24204*CLI> odbc show

ODBC DSN Settings

[/code]

The ODBC Connector seems to be working… so I don’t understand why odbc can connect to the database here, but asterisk can’t?

root@vsrv24204:/home/lalala/src/asterisk-complete/asterisk/1.8# echo "select 1" | isql -v asterisk-connector +---------------------------------------+ | Connected! | | | | sql-statement | | help [tablename] | | quit | | | +---------------------------------------+ SQL> select 1 +---------------------+ | 1 | +---------------------+ | 1 | +---------------------+ SQLRowCount returns 1 1 rows fetched SQL>

Here’s what I have in odbc.ini and res_odbc.conf:

odbc.ini

[asterisk-connector] Description = MySQL connection to 'asterisk' database Driver = MySQL Database = asterisk Server = localhost UserName = lalala Password = password Port = 3306 Socket = /var/run/mysqld/mysqld.sock

res_odbc.conf

asterisk] enabled => yes dsn => asterisk-connector username => lalala password => password pooling => no limit => 0 pre-connect => yes

I’m a bit stuck here, so I’d be very thankful for your help! If you need anymore information just say so :smile:

Greetings,
Eggat

Can I assume that the missing ‘[’ on the desriptor in the posted res_odbc.conf was a copy/paste error?

What is your func_odbc.conf look like?

If you do a ‘module reload res_odbc.so’, are there any error messages displayed?

Hi dalenoll, thanks a lot for your reply!

The module reload gives me the following error message:

vsrv24204*CLI> module reload res_odbc.so -- Reloading module 'res_odbc.so' (ODBC resource) == Parsing '/etc/asterisk/res_odbc.conf': == Found [Feb 17 22:28:03] WARNING[23472]: res_odbc.c:802 load_odbc_config: Limit should be a number, not a boolean: '0'. Disabling ODBC class 'asterisk'.

After uncommenting the line ‘limit => 0’ in res_odbc.conf I got the following error message:

vsrv24204*CLI> module reload res_odbc.so [Feb 17 22:36:38] NOTICE[23536]: res_odbc.c:1481 odbc_obj_connect: Connecting asterisk [Feb 17 22:36:38] WARNING[23536]: res_odbc.c:1508 odbc_obj_connect: res_odbc: Error SQLConnect=-1 errno=1045 [unixODBC][MySQL][ODBC 5.1 Driver]Access denied for user 'lalala'@'localhost' (using password: YES) [Feb 17 22:36:38] WARNING[23536]: res_odbc.c:1329 _ast_odbc_request_obj2: Failed to connect to asterisk [Feb 17 22:36:38] NOTICE[23536]: res_odbc.c:902 load_odbc_config: Registered ODBC class 'asterisk' dsn->[asterisk-connector]

My func_odbc.conf looks like this:

[TEST] dsn=asterisk readsql=SELECT tel FROM users WHERE vname='test'

Ok… I figured out what the problem was!

The password I used to connect to the database contained some shell metacharacters…

Thanks!