3

I am trying to connect a java program to a database. I have sajdbc4.jar in the build path and it worked before, but now I keep getting this error when I try to make the connection:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no dbjdbc12 in java.library.path at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.loadLibrary0(Unknown Source) at java.lang.System.loadLibrary(Unknown Source) at sybase.jdbc4.sqlanywhere.IDriver.try_load(IDriver.java:455) at sybase.jdbc4.sqlanywhere.IDriver.(IDriver.java:396) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at java.lang.Class.newInstance(Unknown Source) at java.util.ServiceLoader$LazyIterator.nextService(Unknown Source) at java.util.ServiceLoader$LazyIterator.next(Unknown Source) at java.util.ServiceLoader$1.next(Unknown Source) at java.sql.DriverManager$2.run(Unknown Source) at java.sql.DriverManager$2.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.sql.DriverManager.loadInitialDrivers(Unknown Source) at java.sql.DriverManager.(Unknown Source) at Main.main(Main.java:26)

Can someome please help me? Can't find anything abount this issue online.

2
  • Looks like you are missing a native library (.dll on Windows, .so on Linux) - does that help with anything? Sep 19, 2015 at 19:41
  • sajdbc4.jar is not a pure Java driver and requires the dbjdbc12.dll - just as the error message says. See item 5) here: scn.sap.com/community/sql-anywhere/blog/2014/05/02/…
    – user330315
    Sep 19, 2015 at 20:28

3 Answers 3

3

For windows find this file in your computer:

dbjdbc12.dll

For linux find this file:

libdbjdbc12.so

Put the location of this file on the java.library.path either with a command line option:

java -Djava.library.path=DIRECTORYWITHDLL ...

or using System.setProperty in your code:

System.setProperty("java.library.path","DIRECTORYWITHDLL");
0

For Linux, you need to add the dbjdbc12.so to java.library.path using:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/some/path/that/contain/dbjdbc12.so

this is the same for dbjdbc16 also. Since, sybase.jdbc4 driver need this file. Please refer- https://blogs.sap.com/2014/05/02/connecting-to-sql-anywhere-using-jdbc-2/#:~:text=jar%20is%20in%20the%20classpath,Connection%20con%20%3D%20DriverManager.

Similarly, for windows add dbjdbc12.dll file.

0

For SQL Anywhere 17 libdbjdbc17.so was not suffiecient, it was then complaning about the next file:

failed: java.lang.UnsatisfiedLinkError: /usr/local/tomcat/native-jni-lib/libdbjdbc17.so: libdbtasks17_r.so: cannot open shared object file: No such file or directory

So I ended up adding all files from the lib64 folder from the Database client (after I installed it on some other linux machine) to my tomcat lib path and it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.