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