on 2011 Nov 18 6:29 AM
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?
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.)
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.
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.
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.
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?
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
.
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).
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...
User | Count |
---|---|
71 | |
11 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.