Hi, I successfully installed SQL Anywhere 17 on a Linux environment. I am able to connect to it with various client applications, using the jconn4.jar driver. However, I have been directed by the customer to use the sajdbc4.jar driver, and I am running into problem. I developed a simple Java application to try and figure out what I'm doing wrong; I have the source file below. I run it from the command line like this: $ java -classpath .:./sajdbc4.jar -Djava.library.path=/opt/sqlanywhere17/lib64 DriverTest I get the following error: Connecting to database... java.sql.SQLException: Invalid ODBC handle at sap.jdbc4.sqlanywhere.IDriver.makeODBCConnection(Native Method) at sap.jdbc4.sqlanywhere.IDriver.connect(IDriver.java:809) at java.sql.DriverManager.getConnection(DriverManager.java:571) at java.sql.DriverManager.getConnection(DriverManager.java:215) at DriverTest.main(DriverTest.java:26) Line 26 corresponds to the line where I'm calling the DriverManager.getConnection method. I've tried various combinations of JDBC URL values, and I have made sure that all the shared libraries that sajdbc4.jar needs are indeed in the /opt/sqlanywhere17/lib64 DriverTest folder. Any ideas as to how I can solve this problem? thanks, Gonzalo import java.sql.*; public class DriverTest {
} |
Folks, I had to set an environment variable called LD_LIBRARY_PATH, and have it point to the directory with the shared libraries for SQL Anywhere 17. Using the java.library.path JVM parameter wasn't right. So I was able to run it like this: $ export LD_LIBRARY_PATH=/opt/sqlanywhere17/bin64 $ java -classpath .:./sajdbc4.jar DriverTest thanks, Gonzalo |
This should help you out. http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc01776.1600/doc/html/san1357754912147.html Billy How to Load the SQL Anywhere JDBC 4.0 Driver Ensure that the SQL Anywhere JDBC 4.0 driver is in your class file path. set classpath=%IQDIR%\java\sajdbc4.jar;%classpath% The JDBC 4.0 driver takes advantage of the new automatic JDBC driver registration. The driver is automatically loaded at execution startup when it is in the class file path. Required Files The Java component of the SQL Anywhere JDBC 4.0 driver is included in the sajdbc4.jar file installed into the Java subdirectory of your SAP Sybase IQ installation. For Windows, the native component is dbjdbc16.dll in the bin32 or bin64 subdirectory of your SAP Sybase IQ installation; for Unix, the native component is libdbjdbc16.so. This component must be in the system path. |
There is a discussion about this happening under Windows at http://sqlanywhere-forum.sap.com/questions/16238/error-connecting-remotely-using-sajdbc4jar. Don't know if it will be helpful to you or not.