cancel
Showing results for 
Search instead for 
Did you mean: 

Exception: no dbjdbc17 in java.library.path (in mac and linux only, windows works perfectly)

2,313

Good day for you!

When i try to connect to the database with sajdbc.jar driver i get error message "no dbjdbc17 in java.library.path: /Applications/SQLAnywhere17/System/lib64:...".

System.setProperty("java.library.path","/Applications/SQLAnywhere17/System/lib64/");

Connection con = DriverManager.getConnection(
        "jdbc:sqlanywhere:" +
                "UserID=dba;" +
                "Password=sql;" +
                "Host=127.0.0.1:2638;" +
                "ServerName=srvname;" +
                "DatabaseName=dbname;"
);

This issue only in macos and linux. In windows the same code works perfectly.

echo $SQLANY17

/Applications/SQLAnywhere17/System

ls -l /Applications/SQLAnywhere17/System/lib64/ | grep libdbjdbc17

-r-xr-xr-x 1 user admin libdbjdbc17.dylib

Using jconn4.jar driver give the next error: "SQL Anywhere Error -103: Invalid user ID or password 010HA: The server denied your request to use the high-availability feature. Please reconfigure your database, or do not request a high-availability session."

Does anyone know how to solve this problems?

chris_keating
Product and Topic Expert
Product and Topic Expert
0 Kudos

If I source sa_config.sh, I am able to load the library. Otherwise, I see the behaviour that you report. There must be an environment element that must be defined - typically $SQLANY17 but I have tried that with no luck. Note that on MacOS 10.11, the full path to the library must be used (as documented). Is there a reason to not use sa_config?

0 Kudos

sa_config was called earlier. Unfortunately it doesn't help.

mandres1
Explorer
0 Kudos

I have the same problem.. I want to make a report using BIRT (eclipse) and I get the same error. I'm working in macOS

chris_keating
Product and Topic Expert
Product and Topic Expert
0 Kudos

If you have sourced the environment with sa_config.sh (assuming BASH), the java.library.path should not need to be changed (comment out that line).

Can you check

 ldd $SQLANY17/lib64/libdbjdbc17.so

to see if all shared objects are resolved?

and ensure that LD_LIBRARY_PATH is defined as per the sa_config. And also check in the java app by checking the value with:

System.getProperty( "java.library.path" );
VolkerBarth
Contributor
0 Kudos

FWIW, do you mean the script has been "called" or really be "sourced", as that is an important difference?

0 Kudos
cat ~/.zshrc | grep sa_config

source /Applications/SQLAnywhere17/System/bin64/sa_config.sh

otool -L $SQLANY17/lib64/libdbjdbc17.dylib

/Applications/SQLAnywhere17/System/lib64/libdbjdbc17.dylib: @rpath/libdbjdbc17.dylib (compatibility version 0.0.0, current version 0.0.0) @rpath/libdbtasks17_r.dylib (compatibility version 0.0.0, current version 0.0.0) /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 800.6.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.0.0)

echo $LD_LIBRARY_PATH

/Applications/SQLAnywhere17/System/lib64:

String library_path = System.getProperty( "java.library.path" );
System.out.println("library_path = " + library_path);

library_path = /Applications/SQLAnywhere17/System/lib64:/Applications/SQLAnywhere17/System/lib64:/Users/mrjill/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.

Accepted Solutions (0)

Answers (1)

Answers (1)

The error message "no dbjdbc17 in java.library.path" indicates that the Java Virtual Machine (JVM) is unable to locate the SQL Anywhere JDBC driver's native library. The native library is a platform-specific dynamic link library (DLL) or shared object file that provides the driver's native method implementation.

To resolve this issue, use the following command before initiating the connection to add the directory containing the native library to the JVM's library path:

System.setProperty("java.library.path", "/Applications/SQLAnywhere17/System/lib64/");

You may also try passing the library path as a command-line input to the JVM when launching it:

java -Djava.library.path=/Applications/SQLAnywhere17/System/lib64/ YourMainClass

If you continue to receive the "Invalid user ID or password" error while using the jconn4.jar driver, it is likely that the user ID or password you are using is wrong, or that the database server is not configured to support high-availability connections. You can try connecting to the database server with the same user ID and password that you use with other tools or clients. You may also look for any error messages linked to the high-availability functionality in the database server logs.

If you're still having problems, you may try contacting the SQL Anywhere JDBC driver's provider for assistance.