cancel
Showing results for 
Search instead for 
Did you mean: 

Connection to ASA from java with jdbc

Former Member
0 Kudos
5,873

I should Ubuntu (x32), java 1.7, there is a library sajdbc4.jar with which you can connect to the database. The problem is that when I declare

Class.forName ("sybase.jdbc4.sqlanywhere.IDriver");

cursing the lack of compiler library libdbjdbc12.so I looked java.library.path in a folder, which was empty, unloaded all the libraries that have been bundled with the distribution sybase, now he swears by the other:

Exception in thread "main" java.lang.UnsatisfiedLinkError: / usr/java/packages/lib/i386/libdbjdbc12.so.1: libdbtasks12_r.so: can not open shared object file: No such file or directory

Although this library is next to libdbjdbc12.so.1

What should be done for her to see him all the necessary libraries?

UPD1: there are also other drivers :), took to try them (jtds, jconn4) ... eventually ran into the wrong username / password to the server, driver is worked. My server on cp1251, and the connection is with ubuntu, which means UTF8.

/ / for jconn4
     Class.forName ("com.sybase.jdbc4.jdbc.SybDriver"). NewInstance ());
     String userUTF8 = "db", pswdUTF8 = "sql", dburlUTF8 = "jdbc: sybase: Tds: 192.168.1.1:5344 / testdb";
     String userCP1251 = new String (userUTF8.getBytes ("UTF-8"), "Cp1251");
     String pswdCP1251 = new String (pswdUTF8.getBytes ("UTF-8"), "Cp1251");
     String dburlCP1251 = new String (dburlUTF8.getBytes ("UTF-8"), "Cp1251");
     / / System.out.println (dburlCP1251 + "" + userCP1251 + "" + pswdCP1251);
     Connection con = DriverManager.getConnection (dburlCP1251, userCP1251, pswdCP1251);

/ / for jtds
     Class.forName ("net.sourceforge.jtds.jdbc.Driver"). NewInstance ());
     String userUTF8 = "db", pswdUTF8 = "sql", dburlUTF8 = "jdbc: jtds: sybase 😕 / 192.168.1.1:5344 / testdb";
     String userCP1251 = new String (userUTF8.getBytes ("UTF-8"), "Cp1251");
     String pswdCP1251 = new String (pswdUTF8.getBytes ("UTF-8"), "Cp1251");
     String dburlCP1251 = new String (dburlUTF8.getBytes ("UTF-8"), "Cp1251");
     / / System.out.println (dburlCP1251 + "" + userCP1251 + "" + pswdCP1251);
     Connection con = DriverManager.getConnection (dburlCP1251, userCP1251, pswdCP1251);

Such are the result of error:

/ / for jconn4
Exception in thread "main" java.sql.SQLException: JZ00L: Login failed. Examine the SQLWarnings chained to this exception for the reason (s).
/ / for jtds
Exception in thread "main" java.sql.SQLException: Login failed
View Entire Topic
jeff_albion
Advisor
Advisor

If you're using SAJDBC (sajbc4.jar), on Linux / UNIX, libdbtasks12_r.so is loaded from the LD_LIBRARY_PATH environment variable (which translates out to the java.library.path value inside the JVM).

Generally, LD_LIBRARY_PATH is specified by sourcing the provided sa_config.(c)sh for your environment before launching Java. What is this value set to for this Java environment?


Also, SQL Anywhere does not support the use of the jTDS driver. Only jConnect and the SAJDBC driver are supported.


If you're using "jconn4.jar" (jConnect), then your URL should have a jConnect URL format:

Connection con = DriverManager.getConnection("jdbc:sybase:Tds:localhost:2638?ServiceName=DatabaseName", "DBA", "sql");
Former Member
0 Kudos
  1. does not work
  2. a great magic, IT'S ALIVE !! ))