Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

unixODBC: SQLConnect fails IM002 (ianywhere 9.0.1)

8 posts in General Discussion Last posting was on 2005-07-15 15:21:09.0Z
Roland Posted on 2005-07-14 12:58:44.0Z
From: Roland <rolandrbox-01@yahoo.de>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: ianywhere.public.general
Subject: unixODBC: SQLConnect fails IM002 (ianywhere 9.0.1)
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: kk158.aachen.utimaco.de
X-Original-NNTP-Posting-Host: kk158.aachen.utimaco.de
Message-ID: <42d66184@forums-1-dub>
Date: 14 Jul 2005 05:58:44 -0700
X-Trace: forums-1-dub 1121345924 194.245.91.158 (14 Jul 2005 05:58:44 -0700)
X-Original-Trace: 14 Jul 2005 05:58:44 -0700, kk158.aachen.utimaco.de
Lines: 64
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:4618
Article PK: 8424

Hi newsgroup,

I try to connect from my own Application via odbc to an iAnywere SQL
Server. But I always get the SQL-Error IM002 after calling SQLConnect().

Here are the version numbers:
iAnywhere 9.0.1
kernel 2.6.11.4 (SuSE 9.3)
SQL_OV_ODBC2

What I have done so far:
- installation of ianywhere 9.0.1
- installation of SuSE unixodbc packages (/usr/lib/libodbc.so)

With the sybase tool scjview, I have created a test database. The
filename is ror.test.db and the server name is ror.test. It was quite
easy to create tables and insert data into the tables. Database owner is
'DBA' with the password 'SQL'.

Then I have written my own odbc-Application in c. The main routine works
very similar like those examples which are described in the ianywhere
documentation:
-create env-handle
-set env-handle attributes (SQL_OV_ODBC3)
-create dbc-handle
-connect to database

I have linked my application to the odbc-lib /usr/lib/libodbc.so.

I started the database like this:
sybase@host:/opt/sybase-asa-9.0.1/SYBSsa9/bin/ > ./dbsrv9 -ud -gk all
../ror.test.db

Using 'netstat' I can see that the server is listening on port 2638.

However, when executing my odbc-Application, I get an error: IM002

SQLGetDiagRec returns somethink like "Data source name not found, and no
default driver specified".

To me it looks like the odbc interface is not setup correctly. So I have
tried different settings in /etc/odbcinst.ini and /etc/odbc.ini without
success.

To my big surprise, I cannot see that my application even opens one of
the ini-files (neither /etc/odbcinst.ini nor /etc/odbc.ini nor
/home/ror/.odbc.ini).

The following command:

ror@host: ~/odbc-test/ > strace ./odbc 2>&1 | grep open

dumps out open-commands for some shared libs but no odbc ini files.

So, what can I do to connect from my application to the database server?

Any help is welcome!

Thanks in advance.

Roland


Greg Fenton Posted on 2005-07-14 13:28:11.0Z
From: Greg Fenton <greg.fenton_NOSPAM_@ianywhere.com>
Organization: iAnywhere Solutions Inc.
User-Agent: Mozilla Thunderbird 1.6.3.2f (Windows/20050317)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: ianywhere.public.general
Subject: Re: unixODBC: SQLConnect fails IM002 (ianywhere 9.0.1)
References: <42d66184@forums-1-dub>
In-Reply-To: <42d66184@forums-1-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: gfenton-t30.sybase.com
X-Original-NNTP-Posting-Host: gfenton-t30.sybase.com
Message-ID: <42d6686b$1@forums-1-dub>
Date: 14 Jul 2005 06:28:11 -0700
X-Trace: forums-1-dub 1121347691 10.25.98.243 (14 Jul 2005 06:28:11 -0700)
X-Original-Trace: 14 Jul 2005 06:28:11 -0700, gfenton-t30.sybase.com
Lines: 25
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:4619
Article PK: 8423


Roland wrote:
>
> SQLGetDiagRec returns somethink like "Data source name not found, and no
> default driver specified".
>

Can you show us the connection string you are using in the attempt to
connect to the database?

Any reason you are trying to use unixODBC rather than iAnywhere's ODBC
driver/manager directly?

BTW: you will likely find better responses to SQLAnywhere on
Linux/Unix/OSX issues if you post to the newsgroup:

sybase.public.sqlanywhere.linux

greg.fenton
--
Greg Fenton
Consultant, Solution Services, iAnywhere Solutions
--------
Visit the iAnywhere Solutions Developer Community
Whitepapers, TechDocs, Downloads
http://www.ianywhere.com/developer/


Roland Posted on 2005-07-14 14:43:11.0Z
From: Roland <rolandrbox-01@yahoo.de>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: ianywhere.public.general
Subject: Re: unixODBC: SQLConnect fails IM002 (ianywhere 9.0.1)
References: <42d66184@forums-1-dub> <42d6686b$1@forums-1-dub>
In-Reply-To: <42d6686b$1@forums-1-dub>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
X-Original-NNTP-Posting-Host: kk158.aachen.utimaco.de
Message-ID: <42d679fa$1@forums-2-dub>
X-Original-Trace: 14 Jul 2005 07:43:06 -0700, kk158.aachen.utimaco.de
Lines: 48
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-Trace: 14 Jul 2005 07:43:08 -0700, forums-2-dub.sybase.com
NNTP-Posting-Host: forums-master.sybase.com
X-Original-NNTP-Posting-Host: forums-master.sybase.com
Date: 14 Jul 2005 07:43:11 -0700
X-Trace: forums-1-dub 1121352191 10.22.108.75 (14 Jul 2005 07:43:11 -0700)
X-Original-Trace: 14 Jul 2005 07:43:11 -0700, forums-master.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:4621
Article PK: 8426

Hi Greg,

thank you for your answer!

> Can you show us the connection string you are using in the attempt to
> connect to the database?

#define DB_SERVER_NAME "ror.test"
#define DB_USER "DBA"
#define DB_PASS "SQL"

.
.

rc = SQLConnect(dbh, (SQLCHAR*) DB_SERVER_NAME, SQL_NTS,
(SQLCHAR*) DB_USER, SQL_NTS,
(SQLCHAR*) DB_PASS, SQL_NTS);




> Any reason you are trying to use unixODBC rather than iAnywhere's ODBC
> driver/manager directly?

Yes! First I have linked my little odbc application to the libodbc
provided by sybase
(/opt/sybase-asa-9.0.1/SYBSsa9/driver/lib/libodbc.so). In this case, the
function SQLConnect() returned -1 and SQLGetDiagRec returned SQLState
0100 with an empty error message.

Then I tried the libodbc.so from /usr/lib. In this case the SQLConnect()
function returns an error as well but the SQLGetDiagRec returned
SQLState IM002 with the appropriate error message.

>
> BTW: you will likely find better responses to SQLAnywhere on
> Linux/Unix/OSX issues if you post to the newsgroup:
>
> sybase.public.sqlanywhere.linux

Thanks! That's where I will post in the future!

I hope the function call syntax may help to analyse what is going wrong!

Thanks again for your help!

Roland


Greg Fenton Posted on 2005-07-14 17:50:19.0Z
From: Greg Fenton <greg.fenton_NOSPAM_@ianywhere.com>
Organization: iAnywhere Solutions Inc.
User-Agent: Mozilla Thunderbird 1.6.3.2f (Windows/20050317)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: ianywhere.public.general
Subject: Re: unixODBC: SQLConnect fails IM002 (ianywhere 9.0.1)
References: <42d66184@forums-1-dub> <42d6686b$1@forums-1-dub> <42d679fa$1@forums-2-dub>
In-Reply-To: <42d679fa$1@forums-2-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: gfenton-t30.sybase.com
X-Original-NNTP-Posting-Host: gfenton-t30.sybase.com
Message-ID: <42d6a5db$1@forums-1-dub>
Date: 14 Jul 2005 10:50:19 -0700
X-Trace: forums-1-dub 1121363419 10.25.98.243 (14 Jul 2005 10:50:19 -0700)
X-Original-Trace: 14 Jul 2005 10:50:19 -0700, gfenton-t30.sybase.com
Lines: 46
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:4623
Article PK: 8429


Roland wrote:
>> Any reason you are trying to use unixODBC rather than iAnywhere's ODBC
>> driver/manager directly?
>
>
> Yes! First I have linked my little odbc application to the libodbc
> provided by sybase
> (/opt/sybase-asa-9.0.1/SYBSsa9/driver/lib/libodbc.so). In this case, the
> function SQLConnect() returned -1 and SQLGetDiagRec returned SQLState
> 0100 with an empty error message.

That libodbc.so is the driver manager provided for working with the ODBC
drivers SQLAnywhere Studio provides for working with *other* RDMBS's
(e.g. wqora19.so (Oracle), wqase19.so (Sybase ASE), etc...)

ASA's ODBC driver (libdbodbc9.so or libdbodbc9_r.so) is actually also a
driver manager (for itself). So you can "make" it into a driver manager by:

$ cd $ASANY9/lib
$ ln -s libdbodbc9_r.so libodbc.so

And then linking against this symlink (-L$ASANY9/lib)

I would consider using this approach over using a 3rd party driver
manager unless you have a particular need for that other manager.

You might consider compiling the example "odbc" application that ships
in $ASANY9/samples/asa/c. To build it, I currently do:

$ cd $ASANY9/samples/asa/c
$ export PLATFORM=LINUX
$ export ODBC=$ASANY9/lib
$ make all

(Note: I created the symlink for the driver manager as per above before
trying to compile the sample).

Hope this helps,
greg.fenton
--
Greg Fenton
Consultant, Solution Services, iAnywhere Solutions
--------
Visit the iAnywhere Solutions Developer Community
Whitepapers, TechDocs, Downloads
http://www.ianywhere.com/developer/


Greg Fenton Posted on 2005-07-14 18:19:53.0Z
From: Greg Fenton <greg.fenton_NOSPAM_@ianywhere.com>
Organization: iAnywhere Solutions Inc.
User-Agent: Mozilla Thunderbird 1.6.3.2f (Windows/20050317)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: ianywhere.public.general
Subject: Re: unixODBC: SQLConnect fails IM002 (ianywhere 9.0.1)
References: <42d66184@forums-1-dub> <42d6686b$1@forums-1-dub> <42d679fa$1@forums-2-dub> <42d6a5db$1@forums-1-dub>
In-Reply-To: <42d6a5db$1@forums-1-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: gfenton-t30.sybase.com
X-Original-NNTP-Posting-Host: gfenton-t30.sybase.com
Message-ID: <42d6acc9$1@forums-1-dub>
Date: 14 Jul 2005 11:19:53 -0700
X-Trace: forums-1-dub 1121365193 10.25.98.243 (14 Jul 2005 11:19:53 -0700)
X-Original-Trace: 14 Jul 2005 11:19:53 -0700, gfenton-t30.sybase.com
Lines: 27
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:4624
Article PK: 8428


Greg Fenton wrote:
>
> ASA's ODBC driver (libdbodbc9.so or libdbodbc9_r.so) is actually also a
> driver manager (for itself). So you can "make" it into a driver manager
> by:
>
> $ cd $ASANY9/lib
> $ ln -s libdbodbc9_r.so libodbc.so
>
> And then linking against this symlink (-L$ASANY9/lib)
>

I know that we had this information documented in the welcome.pdf
document (Readme First for UNIX) and that it was being migrated to the
online docs (in the Programming Guide), but it seems that this
information has been dropped.

I have posted an enhancement request to the docs team.

greg.fenton
--
Greg Fenton
Consultant, Solution Services, iAnywhere Solutions
--------
Visit the iAnywhere Solutions Developer Community
Whitepapers, TechDocs, Downloads
http://www.ianywhere.com/developer/


Roland Posted on 2005-07-15 10:39:04.0Z
From: Roland <rolandrbox-01@yahoo.de>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: ianywhere.public.general
Subject: Re: unixODBC: SQLConnect fails IM002 (ianywhere 9.0.1)
References: <42d66184@forums-1-dub> <42d6686b$1@forums-1-dub> <42d679fa$1@forums-2-dub> <42d6a5db$1@forums-1-dub>
In-Reply-To: <42d6a5db$1@forums-1-dub>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: kk158.aachen.utimaco.de
X-Original-NNTP-Posting-Host: kk158.aachen.utimaco.de
Message-ID: <42d79248$1@forums-1-dub>
Date: 15 Jul 2005 03:39:04 -0700
X-Trace: forums-1-dub 1121423944 194.245.91.158 (15 Jul 2005 03:39:04 -0700)
X-Original-Trace: 15 Jul 2005 03:39:04 -0700, kk158.aachen.utimaco.de
Lines: 38
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:4627
Article PK: 8435

Hi Greg,

thanks again for your help!

I have built now my odbc application by linking against libdblib9 from
$ASANY9/lib (=/opt/sybase-asa-9.0.1/SYBSsa9/lib) and libodbc from
$ASANY9/drivers/lib (=/opt/sybase-asa-9.0.1/SYBSsa9/drivers/lib).

The application works fine and connects to the ASA! Before I had to
adapt some paths in /etc/odbcinst.ini and /etc/odbc.ini which were
copied from /opt/sybase-asa-9.0.1/SYBSsa9/samples/asa/c/.odbcinst.ini
and .odbc.ini.

> ASA's ODBC driver (libdbodbc9.so or libdbodbc9_r.so) is actually also a
> driver manager (for itself). So you can "make" it into a driver manager
> by:
>
> $ cd $ASANY9/lib
> $ ln -s libdbodbc9_r.so libodbc.so
>
> And then linking against this symlink (-L$ASANY9/lib)

When linking against libdbodbc9, my application also connected to the
ASA with the same files /etc/odbcinst.ini and /etc/odbc.ini.

However I cannot see that my application reads one of the files
/etc/odbcinst.ini or /etc/odbc.ini. But without these files the
connection cannot be established.

But anyway, my application connects now without problems. I can go on
evaluating ASA.

Thank you for your help which I appriciate a lot. Have a nice weekend.

Best regards,

Roland


Greg Fenton Posted on 2005-07-15 13:45:13.0Z
From: Greg Fenton <greg.fenton_NOSPAM_@ianywhere.com>
Organization: iAnywhere Solutions Inc.
User-Agent: Mozilla Thunderbird 1.6.3.2f (Windows/20050317)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: ianywhere.public.general
Subject: Re: unixODBC: SQLConnect fails IM002 (ianywhere 9.0.1)
References: <42d66184@forums-1-dub> <42d6686b$1@forums-1-dub> <42d679fa$1@forums-2-dub> <42d6a5db$1@forums-1-dub> <42d79248$1@forums-1-dub>
In-Reply-To: <42d79248$1@forums-1-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: gfenton-t30.sybase.com
X-Original-NNTP-Posting-Host: gfenton-t30.sybase.com
Message-ID: <42d7bde9$1@forums-1-dub>
Date: 15 Jul 2005 06:45:13 -0700
X-Trace: forums-1-dub 1121435113 10.25.98.243 (15 Jul 2005 06:45:13 -0700)
X-Original-Trace: 15 Jul 2005 06:45:13 -0700, gfenton-t30.sybase.com
Lines: 68
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:4628
Article PK: 8436


Roland wrote:
>
> I have built now my odbc application by linking against libdblib9 from
> $ASANY9/lib (=/opt/sybase-asa-9.0.1/SYBSsa9/lib) and libodbc from
> $ASANY9/drivers/lib (=/opt/sybase-asa-9.0.1/SYBSsa9/drivers/lib).
>

Roland,

As my previous email stated, drivers/lib/libodbc.so is NOT the ASA
driver manager but a third party driver manager specifically designed to
work with other (i.e. non-ASA) ODBC drivers.

I would suggest you do not use this third party driver manager but
instead use the symlink idea I pointed out previously.

>
> When linking against libdbodbc9, my application also connected to the
> ASA with the same files /etc/odbcinst.ini and /etc/odbc.ini.
>
> However I cannot see that my application reads one of the files
> /etc/odbcinst.ini or /etc/odbc.ini. But without these files the
> connection cannot be established.
>

I'm not clear as to what you are saying is not working.

The ASA driver manager (again, the symlink to libdbodbc9.so) will read
DSN entries from the .odbc.ini file it finds based on the algorithm
described in the ASA 9.x online docs:

ASA Database Administration Guide
Connecting to a Database
Working with ODBC data sources
- Using ODBC data sources on UNIX

which is:

File location
The database server looks for the .odbc.ini file in the following
locations:

1. ODBCINI environment variable
2. ODBCHOME and HOME environment variables
3. The user's home directory
4. The path

I also suggest that people use the "dbdsn" command-line utility that
ships with ASA for administrating DSNs rather than manually editing the
.odbc.ini. That utility uses the exact same library for
locating/reading/writing DSNs as does the ASA ODBC client library.

For more info on dbdsn, see:

ASA Database Administration Guide
Database Administration Utilities
The Data Source utility
- Managing ODBC data sources using the dbdsn command-line utility

Hope this helps,
greg.fenton
--
Greg Fenton
Consultant, Solution Services, iAnywhere Solutions
--------
Visit the iAnywhere Solutions Developer Community
Whitepapers, TechDocs, Downloads
http://www.ianywhere.com/developer/


Roland Posted on 2005-07-15 15:21:09.0Z
From: Roland <rolandrbox-01@yahoo.de>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: ianywhere.public.general
Subject: Re: unixODBC: SQLConnect fails IM002 (ianywhere 9.0.1)
References: <42d66184@forums-1-dub> <42d6686b$1@forums-1-dub> <42d679fa$1@forums-2-dub> <42d6a5db$1@forums-1-dub> <42d79248$1@forums-1-dub> <42d7bde9$1@forums-1-dub>
In-Reply-To: <42d7bde9$1@forums-1-dub>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
X-Original-NNTP-Posting-Host: kk158.aachen.utimaco.de
Message-ID: <42d7d45f@forums-2-dub>
X-Original-Trace: 15 Jul 2005 08:21:03 -0700, kk158.aachen.utimaco.de
Lines: 52
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-Trace: 15 Jul 2005 08:21:06 -0700, forums-2-dub.sybase.com
NNTP-Posting-Host: forums-master.sybase.com
X-Original-NNTP-Posting-Host: forums-master.sybase.com
Date: 15 Jul 2005 08:21:09 -0700
X-Trace: forums-1-dub 1121440869 10.22.108.75 (15 Jul 2005 08:21:09 -0700)
X-Original-Trace: 15 Jul 2005 08:21:09 -0700, forums-master.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:4629
Article PK: 8432

Hi Greg,

OK, my application is now linked to libdbodbc9.so and works fine.

>> When linking against libdbodbc9, my application also connected to the
>> ASA with the same files /etc/odbcinst.ini and /etc/odbc.ini.
>>
>> However I cannot see that my application reads one of the files
>> /etc/odbcinst.ini or /etc/odbc.ini. But without these files the
>> connection cannot be established.

> I'm not clear as to what you are saying is not working.

Sorry, right now I cannot reproduce this behaviour. If it occurs again,
I will examine this probleme. What I have seen yesterday evening was
that the SQLConnect() function returned with an error if the files
/etc/odbcinst.ini and /etc/odbc.ini are removed. Maybe I got mixed up
with the environmen variables (ODBCHOME, ODBCINI). Or I am completely
blind ;-)


> The ASA driver manager (again, the symlink to libdbodbc9.so) will read
> DSN entries from the .odbc.ini file it finds based on the algorithm
> described in the ASA 9.x online docs:
>
> 1. ODBCINI environment variable
> 2. ODBCHOME and HOME environment variables
> 3. The user's home directory
> 4. The path
>

I use the linux utility strace to trace system-calls like 'open()'. I
have created the sample odbc binary from $ASANY9/samples/asa/c.

I start the ASA sample odbc binary and trace system calls like

user@host: /opt/sybase-asa-9.0.1/samples/asa/c > strace ./odbc 2>&1 |
grep open

But there is no open command for a file like '.odbc.ini'. Even if I call
strace with '-F' or '-f' or '-ff'. I cannot see that this binary reads
any .odbc.ini file.

However there are big chances that I'll spend the weekend reading ASA docs.

Thanks for your help.

Roland