[Devel] unixODBC connection

Lenir lenirsantiago at yahoo.com
Fri Dec 23 22:43:48 CET 2005


Guys,

Im trying to use the unixodbc module using the FreeTDS drivers. I'm trying
to connect to Sybase. 

I can connect fine using both isql and tsql and connecting by both: using
DSN or specifying host, port UID and PWD, so I know for a fact that unixODBC
and FreeTDS are installed and working properly.

 

Here are my config files for unixODBC and FreeTDS:
[root at home ~]# cat /etc/odbc.ini 

[SYBASE]

Description             = FreeTDS ODBC Data Source

UID                     = admin

PWD                     = password

Driver                  = FreeTDS

Server                  = xx.xx.xx.xx

Port                    = 5000

Database                = database

DSN                     = database

UseCursor               = 1

TDS_Version             = 5

 

 [root at home ~]# cat /etc/odbcinst.ini 

# Example driver definitinions

#

#

[FreeTDS]

Description             = FreeTDS ODBC Driver

Driver          = /usr/lib/libtdsodbc.so

 

[root at home ~]# cat /etc/freetds.conf 

[global]

        tds version = 4.2

        dump file = /tmp/freetds.log

        debug level = 10

 

[SYBASE]

        host = xx.xx.xx.xx

        port = 5000

        tds version = 5.0

 

in my openser.cfg file I use the following for all DB related parameters

fifo_db_url="unixodbc://admin:password@xx.xx.xx.xx/SYBASE"

modparam("acc|usrloc|permissions|domain|speeddial|alias_db", "db_url",
"unixodbc://admin:password@xx.xx.xx.xx/SYBASE")

modparam("avpops", "avp_url","unixodbc://admin:password@xx.xx.xx.xx/SYBASE")

 

When I run openser I get the following:



WARNING: no fork mode 

stateless - initializing

 0(0) Maxfwd module- initializing

 0(0) ACC - initializing

 0(0) AUTH module - initializing

textops - initializing

Failed to connect

 

The driver reported the following diagnostics whilst running
SQLDriverConnect

 

IM007:1:0:[unixODBC][FreeTDS][SQL Server]Could not find UID parameter

HYC00:2:0:[unixODBC][FreeTDS][SQL Server]Driver not capable

 0(0) ERROR:domain_db_init: cannot initialize database connection

 0(0) init_mod(): Error while initializing module domain

ERROR: error while initializing modules.

 

For whatever reason the module is not picking up the UID and PWD from the
db_url parameters.

 

The way I fixed the problem was by changing the file my_con.c, line 68: 

 

From:

        sprintf( stringDNS, "%s%s%s", "DSN=", id->database, ";");

to:

        sprintf( stringDNS, "%s%s%s", "DSN=", id->database,
";UID=username;PWD=password;");

 

And now works fine. Also, to add debug to figure out which SQL queries fail,
I changed the file dbase.c line 77:

 

From:

                LOG(L_ERR, "Return value: %d\n", ret);

To:

                LOG(L_ERR, "Return value: %d, Performing query: %s\n", ret,
_s);

 

Now everytime  a query fails it'll say the result msg, as well as the actual
query that failed.

 

Lenir

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://openser.org/pipermail/devel/attachments/20051223/d0954e0d/attachment.html


More information about the Devel mailing list