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.

Hello,

I cannot get the sajdbc4 working. I get the error:

java.lang.ClassNotFoundException: sap.jdbc4.sqlanywhere.IDriver

From web research I understand that the most common reason for this is that sajdbc4.jar is not on the classpath. I have confirmed that it IS on the classpath by running the following code:

final ClassLoader cl = ClassLoader.getSystemClassLoader();
URL[] urls = ((URLClassLoader)cl).getURLs();
for(final URL url: urls){
    System.out.println(url.getFile());
}

This produces:

... (other jars)
08:45:53,339 INFO  [stdout] (default task-2) /C:/Program Files/wildfly-10.1.0.Final/modules/Sybase/main/sajdbc4.jar

I understand that I should not have to register the driver but I am doing so to try and debug this so I immediately follow the above with:

DriverManager.registerDriver((Driver)(Class.forName("sap.jdbc4.sqlanywhere.IDriver")).newInstance());

This generates

java.lang.ClassNotFoundException: sap.jdbc4.sqlanywhere.IDriver

I also know that the native components must be on the system path. Since the docs fail to state if this is supposed to be done on the SQL Anywhere 17 server machine or on the client machine I have done this on both.

So, I am left with the question "What is the class name and connection string to be used with sajdbc4?"

Also, can someone state whether it is the server or client that must have the native components on the system path?

Thank you.

asked 03 Apr '18, 12:26

AlK's gravatar image

AlK
735313554
accept rate: 37%

2

Can you please run and post the output from:

java -cp C:\Program Files\wildfly-10.1.0.Final\modules\Sybase\main\sajdbc4.jar sap.jdbc4.sqlanywhere.IBuildNum

(Note: be aware of any unexpected line breaks).

(03 Apr '18, 15:39) Chris Keating
Replies hidden

Hi Chris,

Thank you very much for responding.

I ran what you posted (however, I added quotes around the path) as one command line with a space between ".jar" and "sap.". Here is the result: java -cp "C:\Program Files\wildfly-10.1.0.Final\modules\Syb ase\main\sajdbc4.jar" sap.jdbc4.sqlanywhere.IBuildNum

17.0.4.2053

Thanks.

(03 Apr '18, 16:18) AlK
1

That test was to confirm that the jar can be found and executed. It also confirms that the sap.jdbc4.sqlanywhere.IDriver is the correct driver class name.

The native components required by the SA JDBC driver must be available to the client (i.e., in the same directory, on the path). But the issue you are encountering is not related to not finding those native libraries. I would recommend testing this outside of the WildFly environment to confirm that the jar is working correctly - the documentation has a sample that you can use for this test.

(03 Apr '18, 17:17) Chris Keating

Hi Chris,

Thanks for confirming that the support files must be on the client. I added them 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 '18, 13:34

AlK's gravatar image

AlK
735313554
accept rate: 37%

converted 05 Apr '18, 13:35

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:

×86
×44

question asked: 03 Apr '18, 12:26

question was seen: 2,209 times

last updated: 05 Apr '18, 13:34