cancel
Showing results for 
Search instead for 
Did you mean: 

sybase.jdbc4.sqlanywhere.IDriver problems, java hangs when connecting

Former Member
0 Kudos
10,024

When connecting to a Sybase SQL Anywhere server via jdbc java hangs. License Sybase SQL Anywhere Web Edition. Driver: sajdbc4.jar -> sybase.jdbc4.sqlanywhere.IDriver
The jdbc connection string:
sqlanywhere:DSN=database;UID=sa;PWD=123456; DBF=database;host=192.168.5.5;port=2638;charset=utf8

The server is configured under Linux.
Connected via Sybase Central under Windows is stable.
SQL Anywhere Network Server Version 12.0.1.3152
Web edition, licensed only for web use.
Running Linux 2.6.38-11-server #50-Ubuntu SMP Mon Sep 12 21:34:27 UTC 2011 on X86_64
Server built for X86_64 processor architecture

Tell me please, maybe I need to use a different driver, or the connection string?

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Try removing the space in the connection string, and also remove "DSN=database;". Since it is a type 2 JDBC driver, it does not require a DSN. See the note at end of the "New SQL Anywhere TYPE-2 JDBC driver" topic here.

VolkerBarth
Contributor
0 Kudos

Once loaded, connections using the SQL Anywhere JDBC driver can be made by using the URL jdbc:sqlanywhere:connection-string-parameters. The connection-string-parameters are the standard connection parameters required to connect to SQL Anywhere. Note that the application no longer needs to specify DRIVER= or DSN= in connection-string-parameters when using the SQL Anywhere JDBC driver.

Well, the doc part seem to imply you don't need to specify a DSN - does it really mean you mustn't specify a DSN?

(I always had the impression most non-ODBC-bases client interfaces can still use an ODBC DSN to collect connection parameters.)

Former Member
0 Kudos

In the connection string I have no spaces. Simply did not fit with spaces on the page. Without the use of DSN java also hangs on connecting.

Now the connection string is: jdbc:sqlanywhere:UID=sa;PWD=123456;DBF=/opt/bin/sqlanywhere/12/arena-site.db;host=192.168.5.5;port=2638;charset=utf8

By the way if the connection string jdbc:sqlanywhere:charset=utf8, or any other correct connection string, java hangs too.

VolkerBarth
Contributor

Is that database already running on a database server? If so (and I would suggest that), you should specify the name of the running database (DBN=) instead of specifying the database file location (DBF=).

Is there any error you are getting? - Adding the client log with LOG= may help.

Former Member
0 Kudos

If there is a DSN in the URL, the driver may get connection parameters from it. I thought it might be simpler to diagnose the problem if connection parameters only came from the the URL.

VolkerBarth
Contributor
0 Kudos

Thanks to confirm my understanding - and I agree that for diagnosis, explicit connection params are much easier:)

Former Member
0 Kudos

Note also that the DBF parameter should only be used when the client, database server, and database file are all on the same computer.

You mentioned that Sybase Central can connect from a Windows computer, but I assume (from your DBF path) that your Java application is running on Linux. Can Sybase Central connect when run on the same computer as your Java application?

FYI, you can see the connection string for a DSN by using:

ddsn -b -g <dsn_name>
It might be helpful to run that on the Windows computer you used for Sybase Central, with the <dsn_name> that worked in Sybase Central.

Have you tried running the Java program in a debugger, eg. to get a stack trace where you application is hanging?

VolkerBarth
Contributor
0 Kudos

FWIW, the tool is called dbdsn, so the command would be

dbdsn -b -g <dsn_name>

Former Member
0 Kudos

As I understand it, Sybase Central uses jodbc4.jar as a driver (ianywhere.ml.jdbcodbc.jdbc4.IDriver) and the line connecting him:
jdbc:ianywhere:UID=sa;PWD=123456;DSN=arena-site;ASTART=No;host=192.168.5.5:2638


But this raises another problem: a shortage of dbjdbc12 in java CLASS_PATH, and after adding the call to create a connection gives an error: [Sybase][ODBC Driver Manager] Unable to load resource file.

Former Member
0 Kudos

In Windows, where Sybase Central

dbdsn.exe -b -g arena-site
SQL Anywhere Data Source Utility Version 12.0.1.3152
Cannot find user data source "arena-site"

The connection string I looked in the profile of Sybase Central connection

Former Member
0 Kudos

Yes Sybase Central and other SQL Anywhere Java administration tools use our internal JDBC-ODBC bridge driver to access ODBC datasources. I wasn't suggesting you switch to use that driver, just that you could use dbdsn to see a connection string that worked, albeit via ODBC.

Former Member
0 Kudos

Yes, sorry for the typo.

VolkerBarth
Contributor
0 Kudos

For those small things, sometimes it would be easier if one just could edit comments like questions and answers...

Graeme, is that a feature TBD?:)

Former Member
0 Kudos

If it's a system DSN use -gs instead of -g or -gu (dbdsn syntax). You may also need to run in an elevated command prompt with the same bitness as the DSN (eg. %SQLANY12%\\bin32\\dbdsn.exe or %SQLANY12%\\bin64\\dbdsn.exe as Volker has also suggested).

VolkerBarth
Contributor
0 Kudos

You might also check for system DSNs (and possibly have to use the 32-bit or 64-bit version of dbdsn, according to the bitness of your application / Sybase Central):

"%SQLANY12%bin32dbdsn.exe" -b -gs arena-site
"%SQLANY12%bin64dbdsn.exe" -b -gs arena-site

Former Member
0 Kudos

Agreed. Comments are editable, but only for a limited time (60 minutes). However one can still delete and re-comment as a workaround.

Graeme said that timeout doesn't seem to be an editable setting. 😞

VolkerBarth
Contributor
0 Kudos

The 60 minutes timespan is useful to edit one's own comments. (At least I'm a "heavy user" of that feature.)

Nevertheless, one is not allowed to edit other's comments, even in the first 60 minutes.


Now and then, I convert comments to answers temporarily to edit then and convert them back...however, this doesn't work well for such hierarchical comments as in this thread, so I would not dare to do so here...