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?

asked 18 Nov '11, 06:29

xema's gravatar image

xema
1132
accept rate: 0%

edited 15 Mar '13, 21:32

Mark%20Culp's gravatar image

Mark Culp
23.2k9132272


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
2.7k11843
accept rate: 30%

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

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

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

(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 12.0.1.3152
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

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:

×412
×130
×85
×67

question asked: 18 Nov '11, 06:29

question was seen: 5,190 times

last updated: 15 Mar '13, 21:32