The forum will be down for scheduled maintenance on Saturday, March 4 beginning at 10am EST. Actual downtime is unknown but may be several hours.

I've written a JDBC application that connects to a ODBC DSN. The local Sybase 10 system DSN called TEST connects to a running Sybase database server using TCP. When tested the DSN connects to the remote server successfully

On the local system DBISQL -c "DSN=TEST;USERID=dba;password=password" also connects fine

But when I attempt to connect to the local DSN using JDBC code below I get error [Sybase][ODBC Driver][SQL Anywhere]Database server not found)

Class.forName("ianywhere.ml.jdbcodbc.IDriver"); con = DriverManager.getConnection("jdbc:odbc:Driver=SQL Anywhere 10;DSN=TEST;;uid=dba;pwd=password");

If I run the same code on the same PC as the Sybase DB server the jdbc code works fine.

Why can't JDBC connect to local DSNs that connect to remote sybase DB servers?

asked 17 Mar '14, 19:31

GeoffE's gravatar image

GeoffE
16112
accept rate: 0%


My guess is that you created the DSN for a specific bitness (i.e. either 32-bit or 64-bit) but the JAVA VM is a different bitness. Trying creating the DSN for both 32-bit and 64-bit binaries.

permanent link

answered 18 Mar '14, 08:58

Karim%20Khamis's gravatar image

Karim Khamis
5.6k53870
accept rate: 40%

Note: Bitness of the DSN only matters if you are creating a SYSTEM DSN (rather than a USER DSN). If it is a SYSTEM DSN that you are trying to set up, then use \windows\SysWOW64\odbcad32.exe to set up the 32-bit SYSTEM DSN.

(18 Mar '14, 09:48) JBSchueler
Replies hidden

Bitness of the DSN only matters if you are creating a SYSTEM DSN (rather than a USER DSN)

Are you 100% sure of that? It differs from my experience.

(18 Mar '14, 10:03) Breck Carter

Well, it meets my experience and fits well to John's answer on your older question:

Please explain the ODBC Administrator situation in 64-bit Windows 7

Aside: I just stumbled over this again yesterday...:(

(18 Mar '14, 12:18) Volker Barth

You can run this at the Command Prompt to check out my claim:

  1. To list 64-bit System DSNs: reg query HKLM\SOFTWARE\ODBC\ODBC.INI /s

  2. To list 32-bit System DSNs: reg query HKLM\SOFTWARE\Wow6432Node\ODBC\ODBC.INI /s

  3. To list User DSNs: reg query HKCU\SOFTWARE\ODBC\ODBC.INI /s

HKLM is the LOCAL MACHINE hive.

HKCU is the CURRENT USER hive (this hive is bitness-agnostic).

Hence, there is no HKCU\SOFTWARE\Wow6432Node\ODBC\ODBC.INI.

Where things get really interesting is when you are developing 64-bit applications with Visual Studio. VS design-time is 32-bit (in the version that I use) and run-time is 64-bit. So if you are doing something at design-time that requires the System DSN, then you had better make sure that you have the 32-bit DSN.

(19 Mar '14, 14:59) JBSchueler

Have your tried using the iAnywhere JDBC driver. Try something like this ...

        // Open the connection. May throw a SQLException.
        DriverManager.registerDriver( (Driver)
            Class.forName(
            "ianywhere.ml.jdbcodbc.jdbc3.IDriver").newInstance()
            );

        Connection con = DriverManager.getConnection(
            "jdbc:ianywhere:DSN=test" );

If this doesn't work, go to the ODBC administrator and try the Test Connection button for your DSN. If the connection fails, then you haven't set up your DSN correctly.

Ref: http://dcx.sybase.com/index.html#1001/en/dbpgen10/pg-jdbc-s-3454968.html

permanent link

answered 18 Mar '14, 09:40

JBSchueler's gravatar image

JBSchueler
1.9k2836
accept rate: 16%

If the jvm is 32bit, use windowsSysWOW64odbcad32.exe to set up the 32-bit SYSTEM DSN. Otherwise just create default 64bit SYSTEM DSN.

After create it, please try to test the connection in the odbc manager.

permanent link

answered 18 Mar '14, 21:22

Xiong%20He's gravatar image

Xiong He
162
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×66

question asked: 17 Mar '14, 19:31

question was seen: 1,132 times

last updated: 19 Mar '14, 15:01