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 |
If you're using SAJDBC (sajbc4.jar), on Linux / UNIX, Generally, 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");
(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 Now, to answer your question, you will need to specify the If you specified the default directory during installation, the property would point to 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
Did as you wrote, it does not work. Driver is not loaded.
(13 Dec '12, 02:18)
sonniy
|