cancel
Showing results for 
Search instead for 
Did you mean: 

Why am I getting "Invalid ODBC handle" when using sajdbc4?

0 Kudos
5,596

Hello,

I cannot get sajdbc4 to work under Linux when trying to connect to a High Availability server system. I have successfully configured it for use with WildFly under Windows but when I try to recreate this same setup under Ubuntu 16.0.4 I get the following error as soon as I try to establish a connection to SQL Anywhere 17:

java.sql.SQLException: Invalid ODBC handle

java -XshowSettings:properties

shows:

java.library.path = /usr/java/packages/lib/amd64
        /usr/lib64
        /lib64
        /lib
        /usr/lib

I have placed in /lib64 the following files and created symbolic links as described in the documentation:

drwxr-xr-x  2 root   root   4.0K Apr  9 23:35 .
drwxr-xr-x 23 root   root   4.0K Apr  8 18:07 ..
lrwxrwxrwx  1 root   root     32 Jan 15 02:51 ld-linux-x86-64.so.2 -> /lib/x86_64-linux-gnu/ld-2.23.so
lrwxrwxrwx  1 root   root     17 Apr  9 23:33 libdbicu17_r.so -> libdbicu17_r.so.1
-rwxrwxrwx  1 wizard wizard 1.7M Apr  9 22:03 libdbicu17_r.so.1
lrwxrwxrwx  1 root   root     17 Apr  9 23:33 libdbicudt17.so -> libdbicudt17.so.1
-rwxrwxrwx  1 wizard wizard 4.1M Apr  9 22:03 libdbicudt17.so.1
lrwxrwxrwx  1 root   root     16 Apr  9 23:34 libdbjdbc17.so -> libdbjdbc17.so.1
-rwxrwxrwx  1 wizard wizard 2.7M Apr  9 22:03 libdbjdbc17.so.1
lrwxrwxrwx  1 root   root     17 Apr  9 23:34 libdbrsa17_r.so -> libdbrsa17_r.so.1
-rwxrwxrwx  1 wizard wizard 2.3M Apr  9 22:03 libdbrsa17_r.so.1
lrwxrwxrwx  1 root   root     19 Apr  9 23:35 libdbtasks17_r.so -> libdbtasks17_r.so.1
-rwxrwxrwx  1 wizard wizard 180K Apr  9 22:03 libdbtasks17_r.so.1

My Connection String looks like:

jdbc:sqlanywhere:Host=[IPAddress]:[Port];DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1;ServerName=[AlternateServerName]

Can someone help me understand what is wrong so I can use sajdbc4 under Linux?

Thank you.

chris_keating
Product and Topic Expert
Product and Topic Expert
0 Kudos

Here is an example of the connection string:

jdbc:sqlanywhere:UID=DBA;PWD=sql;SERVER=mirror_demo_primary

I am not familiar with the DB_CLOSE* options in the context of HA.

Lets start with the basic connection string.

VolkerBarth
Contributor

Invalid ODBC handle

Note that this error might also be related to a missing PATH entry for the native components, cf. that older question, particularly Jeff's answer.

Breck_Carter
Participant
0 Kudos

Try removing DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1;

They have nothing to do with SQL Anywhere.

VolkerBarth
Contributor
0 Kudos

jdbc:sqlanywhere:Host=[IPAddress]:[Port];

Note that you usually have to specify two host names when using HA to be able to reach any of both partners...

0 Kudos

Hi Chris,

I tried again with the exact format you provide and still get "Invalid ODBC handle". But I have a question. In a response to an earlier question you said that ServerName (instead of Server) should be used for connection to a High Availability server. Please elaborate on this. Thanks.

0 Kudos

Hi Volker,

Thanks but I had tried that initially. When it failed I "simplified" it to the single host name and that's what I posted. I should have mentioned I tried it the other way as well. Any other ideas?

0 Kudos

Hi Breck,

I moved your response so I could Reply. I tried again without them but still get the "Invalid ODBC handle". I have used these two parameters for years with the jConnect driver with no issues - I thought they we legitimate. Are you familiar with them/do you know what they are? Thanks.

0 Kudos

HI Volker, When you say PATH do you mean Library Path or executable Path? In my original post I showed why I think that all five of the .so files are on the Library Path. However, The link you supplied (thanks) mentions that the problem is related to the language file. I don't have any such dblg[xx]17 in my SQL Anywhere 17 binary directory.

0 Kudos

Hi Chris,

An additional question. Volker below provide a link that described this problem as being caused by a missing dblg[xx] file. My SQL Anywhere 17 installation's /lib64 (where I found the other five support files) doesn't contain a language file. Is this perhaps the problem? Thanks.

VolkerBarth
Contributor
0 Kudos

you said that ServerName (instead of Server) should be used for connection to a High Availability server

I don't see that earlier question but ServerName and Server are synonyms for the according connection parameter, so that should make no difference.


I guess Chris has pointed out to use the "Alternate server name" as value for the ServerName/Server connection parameter in contrast to the "regular server name".

Cf. that tutorial:

For a HA connection, you would use the alternate server name "...ServerName=mirror_demo_primary;..." instead of the regular server name "...ServerName=mirror_server1;...".

VolkerBarth
Contributor
0 Kudos

I moved your response so I could Reply.

FWIW, you can also reply to an answer - there's an "add new comment" button right beneath each question and answer - to be precise: right beneath the last comment on each question and answer...:)

huber1
Participant
0 Kudos

I am also still not able to get the database connection with the native sajdbc4.jar to work. I got the same error messages as you do.

I asked in the following thread the similar question:

https://sqlanywhere-forum.sap.com/questions/16414/jdbc-driver-for-oracle-data-modeler

VolkerBarth
Contributor
0 Kudos

Hm, I had the impression that FAQ (at least the latest state) was primarily dealing with Mac OS X behaviour changes, which should not apply to AIK's Linux platform ...?

Accepted Solutions (1)

Accepted Solutions (1)

Hi Volker,

Well, it was the language file. Under a Linux installation of SQL Anywhere 17 the language files are not found along with the .so files and a web posting I saw (somewhere else) suggested that this was optional under Linux! That caused me to not proactively go looking for the language files. But since I had exhausted all other known possibilities I went looking, found them and adding one fixed the problem. I note that Sybase/SAP failed to improve the error message as was suggested might be done in the link you supplied.

Also, I don't know how to convert your reply to the answer! If you can explain how I'll do so!

Answers (1)

Answers (1)

VolkerBarth
Contributor

I don't run SA on Linux, so I can only guess. According to the docs:

  1. Environment variables must be set accordingly, including PATH.

  2. JDBC does expect a language file, named dblg[LL]17.res.

I wasn't aware of that but v17 has introduced the Deployment Wizard for Linux/Unix and MAC OS X, so you might give that a try. - For client installs, I have often used the same tool on Windows, and it makes sure the required files and configurations are setup as expected.