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

asked 12 Dec '12, 01:54

sonniy's gravatar image

sonniy
6114
accept rate: 0%

edited 12 Dec '12, 07:18


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");
permanent link

answered 13 Dec '12, 17:11

Jeff%20Albion's gravatar image

Jeff Albion
10.8k171175
accept rate: 25%

edited 13 Dec '12, 17:27

  1. does not work
  2. a great magic, IT'S ALIVE !! ))
(14 Dec '12, 10:11) sonniy

First, since Java 6 released (JDK 1.6 or later), you don't need to load drivers using the Class.forName() method. The drivers are loaded automatically when the JAR file is recognized by the classloader. (About time, right? No more specifying a class name, making your code less dependent on the vendor JDBC JAR file.)

Now, to answer your question, you will need to specify the java.library.path property. Once you point this at the correct directory, the system should do the rest of the work for you.

If you specified the default directory during installation, the property would point to /opt/sqlanywhere12/libXX (where XX is 32 or 64, depending on your architecture).

You can set up this property in the Java command line. It would look something like this:

java -Djava.library.path=/opt/sqlanywhere12/lib64

Finally, your connection URL is bad. For the SQLAnywhere JDBC driver (the one in sajdbc4.jar), the URL should look like this:

jdbc:sqlanywhere:uid=XXX;pwd=YYY;links=tcpip(host=ZZ.ZZ.ZZ.ZZ);eng=ENGINE
permanent link

answered 12 Dec '12, 08:54

Jonathan%20Baker's gravatar image

Jonathan Baker
1961211
accept rate: 22%

Did as you wrote, it does not work. Driver is not loaded.

(13 Dec '12, 02:18) sonniy
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×86
×78
×68

question asked: 12 Dec '12, 01:54

question was seen: 5,320 times

last updated: 14 Dec '12, 10:11