I am not able to get the sajdbc4 driver to work in my Java EE app. I have tried two cases as described below but each fails with a different error. I had the app workinh with jConnect but need to change to sajdbc4 to allow me to connect to a High Availability/Mirrored system but I can't even get the basic driver working.

Case One - what I thought was the straightforward way to do this: 1) Per Ref 1, the 1st step is to add the driver .jar to the classpath. I used Eclipse to add the driver .jar to the classpath and here is what I see added to the classpath file: <classpathentry kind="lib" path="C:/Program Files/SQL Anywhere 17/Java/sajdbc4.jar"/>

2) Per Ref 2, the support files are confirmed to be in the (Linux) directory (from the SQL Anywhere installation): /opt/sqlanywhere17/lib64

3) We don't need to manually load the driver so the code I'm using is (connection string format is from Ref 3:

final String sConnectionURL = "jdbc:sqlanywhere:Host=<ipaddress>:<port>;ServerName=MyHAAlternateServerName";
try {
    synchronized (DriverManager.class) {
        final Properties props = new Properties();
        connection = DriverManager.getConnection(sConnectionURL,props);

This crashes on getConnection() with: 17:17:02,505 ERROR [stderr] (default task-4) java.sql.SQLException: No suitable driver found for jdbc:sqlanywhere:Host=<ipaddress>:<port>;ServerName=MyHAAlternateServerName ... 17:17:02,585 ERROR [io.undertow.request] (default task-4) UT005023: Exception handling request to /OpsServer/run: java.lang.RuntimeException: java.sql.SQLException: No suitable driver found for jdbc:sqlanywhere:Host=<ipaddress>:<port>;ServerName=MyHAAlternateServerName

Case Two - see what happens if we manually load the driver: 1) Same as above.

2) Same as above.

3) We try to manually load the driver 1st as follows:

try {
    // Shouldn't need to manually load driver but we do this to debug.

This crashes on registerDriver() with: ERROR [stderr] (default task-3) java.lang.ClassNotFoundException: sap.jdbc4.sqlanywhere.IDriver from [Module "deployment.MyApp.war:main" from Service Module Loader]

What adds to the confusion is that the app runs under the WildFly Java EE app server. I setup a WildFly DataSource (which I am not yet using) and that requires pointing it at the sajdbc4.jar and also supplying a Connection string. I did this and then ran the "Test Connection" that WildFly provides and we get the message "Successfully created JDBC connection." So that suggests to me that at least the sajdbc4.jar and Connection string are correct. Here are some lines from the Eclipse console that reinforce the apparent fact that the WildFly DataSource facility is able to access the driver:

17:13:22,599 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 33) WFLYJCA0005: Deploying non-JDBC-compliant driver class sap.jdbc4.sqlanywhere.IDriver (version 4.0)
17:13:23,873 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-1) WFLYJCA0018: Started Driver service with driver-name = SybaseSA

What is missing or is incorrect in what I am doing when my app tries to get a connection?

Thank you.

asked 01 Apr, 20:43

AlK's gravatar image

accept rate: 33%

edited 02 Apr, 08:25

Breck%20Carter's gravatar image

Breck Carter

Hi Breck,

Thanks for cleaning up my submission (too tired/too late at night!). Do you have any idea about why I can't get sajdbc4 working?


(02 Apr, 14:08) AlK

Is the directory with the native components (libdbjdbc17.so etc.) contained in the system path?

Other than that wild guess, I have no idea...

(03 Apr, 04:07) Volker Barth
Replies hidden

Hi Volker,

The docs are not clear about this. On which system is this needed? My setup is that SQL Anywhere is running on a Linux box and as part of the SA 17 installation there it apparently set LD_SYSTEM_PATH to include /opt/sqlanywhere17/lib64 which contains these files and the associated links. My CLIENT is running under Win 7. In particular it is a Java EE app running under the WildFly app server. I have always "understood" that the native components referred to are the ones already setup on the Linux box "WHERE SQL ANYWHERE 17" is running. By some chance are we supposed to get these files setup on the client's Win 7 system? I cannot find a single reference in the docs (or frankly anywhere on the web) that make a clear statement about this. Can you clarify this?


(03 Apr, 10:12) AlK

I'm not experienced with SQL Anywhere on Linux, so I can't help with the PATH issue there.

However, the native libraries must be used by the client side, i.e. the client makes use of JDBC to connect to the database server, so the client must also be able to load the native libraries. (For the special case of "server-side connections", the server is its own client here.) If your application is a web application, the client is the web server making the database connection to the database server.

So in my understanding your client is running on Win7.

(03 Apr, 15:41) Volker Barth

As to the connection string: For SQL Anywhere with sajdbc4.jar, I use a similar connection string with the difference, that I also supply UID and PWD parameters within the connection string itself instead of supplying them via the props attribute. I don't know whether that makes a difference. I would always make sure that a simple DBISQL connection from the same machine would work with the exact connection string, as is also makes use of that JDBC driver.

With v16, I can load the driver explicitly via its name "sybase.jdbc4.sqlanywhere.IDriver", for v17 (which I have not tried myself), that would be "sap.jdbc4.sqlanywhere.IDriver", as you have stated.

FWIW, here's an history of SQL Anywhere's JDBC driver usage, it does mention v17 in the comments:

Connecting to SQL Anywhere using JDBC

Given all that, I still think there's is some misconfigration of the classpath or the native libraries...

(03 Apr, 15:55) Volker Barth

Hi Volker,

It looks like you may be right about the misconfiguration. First, I did add the support files to the client but still had a problem. Eclipse is well known for it's poorly documented use (since it's based on 3rd party plugins) so I tried recreating the whole project and somewhere in that got this working. Thanks again.

permanent link

answered 05 Apr, 13:31

AlK's gravatar image

accept rate: 33%

converted 05 Apr, 13:32

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


question asked: 01 Apr, 20:43

question was seen: 69 times

last updated: 05 Apr, 13:31