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
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.
answered 18 Mar '14, 08:58
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.
answered 18 Mar '14, 09:40
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.
answered 18 Mar '14, 21:22