Home > Archive > SQL Anywhere for Linux > July 2005 > ASA 9.0.1 odbc sample: how to use other DB









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author ASA 9.0.1 odbc sample: how to use other DB
Roland

2005-07-22, 7:23 am

Hi NG,

right now, I am evaluating ODBC with Sybase ASA 9.0.1.

I have successfully built the ASA's sample code in $ASANY9/samples/asa/c
with CFAGS+=-g, a link libodbc.so to ASA'S libdbodbc9_r.so, PLATFORM=linux.

The sample binary 'odbc' always connects to the asademo-DB and works
just fine.

I have played a little bit with the source code file odbc.c. The
function SQLConnect() is called in function 'int WSQLEX_Init(void)'. One
of the parameters for SQLConnect is the server name. The source code has
"ASA 9.0 Sample":

SQLConnect(xxx, _DBTEXT( "ASA 9.0 Sample" ), yyy, ...)

If I change this string e.g. to "no server", there is no difference:

SQLConnect(xxx, _DBTEXT( "no server" ), yyy, ...)

and rebuild the odbc binary, it still connects to the asademo database.

I wonder how does the binary know which database to use? The odby binary
does not open any config file as far as I can see. The command

strace ./odbc 2>&1 | grep open

just shows that some shared libs are opened - but no config file.

How can I configure the server name?

Any help is welcome, thanks in advance!

Roland



Reg Domaratzki \(iAnywhere Solutions\)

2005-07-22, 7:23 am

The xxx and yyy that you blanked out in your post were very important.
Here's the entire command :

if( !retcode( SQLConnect( Connection,
_DBTEXT( "ASA 9.0 Sample" ), SQL_NTS,
_DBTEXT( "DBA" ), SQL_NTS,
_DBTEXT( "SQL" ), SQL_NTS ),
NULL ) ) {

The SQLConnect being called is the ODBC SQLConnect call, so the 2nd
parameter is the DSN name, which is defined in .odbc.ini in the same
directory. If you want to connect to a different server, you can either use
dbdsn to change the connection parameters of the "ASA 9.0 Sample" DSN, or
you could create your own DSN and change the code in odbc.c to use your
newly created DSN.

Even when you specify a bad DSN name, a userid of "DBA" and password of
"SQL" is enough to connect to a running database on your local machine,
assuming that "DBA" and "SQL" are a valid uid/pwd combination.

--
Reg Domaratzki, Sybase iAnywhere Solutions
Sybase Certified Professional - Sybase ASA Developer Version 8
Please reply only to the newsgroup

iAnywhere Developer Community : http://www.ianywhere.com/developer
iAnywhere Documentation : http://www.ianywhere.com/developer/product_manuals
ASA Patches and EBFs : http://downloads.sybase.com/swx/sdmain.stm
-> Choose SQL Anywhere Studio
-> Set "Platform Preview" and "Time Frame" to ALL

"Roland" <rolandrbox-01@yahoo.de> wrote in message
news:42e0b7ae@forums
-1-dub...
> Hi NG,
>
> right now, I am evaluating ODBC with Sybase ASA 9.0.1.
>
> I have successfully built the ASA's sample code in $ASANY9/samples/asa/c
> with CFAGS+=-g, a link libodbc.so to ASA'S libdbodbc9_r.so,

PLATFORM=linux.
>
> The sample binary 'odbc' always connects to the asademo-DB and works
> just fine.
>
> I have played a little bit with the source code file odbc.c. The
> function SQLConnect() is called in function 'int WSQLEX_Init(void)'. One
> of the parameters for SQLConnect is the server name. The source code has
> "ASA 9.0 Sample":
>
> SQLConnect(xxx, _DBTEXT( "ASA 9.0 Sample" ), yyy, ...)
>
> If I change this string e.g. to "no server", there is no difference:
>
> SQLConnect(xxx, _DBTEXT( "no server" ), yyy, ...)
>
> and rebuild the odbc binary, it still connects to the asademo database.
>
> I wonder how does the binary know which database to use? The odby binary
> does not open any config file as far as I can see. The command
>
> strace ./odbc 2>&1 | grep open
>
> just shows that some shared libs are opened - but no config file.
>
> How can I configure the server name?
>
> Any help is welcome, thanks in advance!
>
> Roland
>
>
>



Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com