Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

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=;port=2638;charset=utf8

The server is configured under Linux.
Connected via Sybase Central under Windows is stable.
SQL Anywhere Network Server Version
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?

asked 18 Nov '11, 06:29

xema's gravatar image

accept rate: 0%

edited 15 Mar '13, 21:32

Mark%20Culp's gravatar image

Mark Culp

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.

permanent link

answered 18 Nov '11, 14:25

Graham%20Hurst's gravatar image

Graham Hurst
accept rate: 29%

edited 21 Nov '11, 13:01

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.)

(19 Nov '11, 08:38) Volker Barth
Replies hidden

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=;port=2638;charset=utf8

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

(21 Nov '11, 05:48) xema
Replies hidden

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.

(21 Nov '11, 06:21) Volker Barth

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.

(21 Nov '11, 10:23) Graham Hurst

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

(21 Nov '11, 10:35) Volker Barth

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?

(21 Nov '11, 15:33) Graham Hurst

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

dbdsn -b -g <dsn_name>

(22 Nov '11, 03:13) Volker Barth

As I understand it, Sybase Central uses jodbc4.jar as a driver ( and the line connecting him:

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.

(22 Nov '11, 03:27) xema
Replies hidden

In Windows, where Sybase Central

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

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

(22 Nov '11, 03:34) xema
Replies hidden

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.

(22 Nov '11, 10:38) Graham Hurst

Yes, sorry for the typo.

(22 Nov '11, 10:39) Graham Hurst

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?:)

(22 Nov '11, 10:47) Volker Barth

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).

(22 Nov '11, 10:50) Graham Hurst

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

(22 Nov '11, 10:53) Volker Barth

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. :(

(22 Nov '11, 11:12) Graham Hurst

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...

(22 Nov '11, 11:35) Volker Barth
showing 4 of 16 show all flat view
Your answer
toggle preview

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 18 Nov '11, 06:29

question was seen: 9,593 times

last updated: 15 Mar '13, 21:32