Solved

Using JDBC-ODBC bridge

Posted on 1999-01-07
4
872 Views
Last Modified: 2012-06-27
When trying to get a connection over the JDBC-ODBC bridge to an MS Access DB I get an error "Unable to load JdbcOdbc library". The Access ODBC driver is properly installed, since I can connect to the DB using a different prog. language. In the JDBC manual it says there was no special install procedure necessary to enable JDBC-ODBC. Below there's a dump of the messages displayed. The JdbcOdbc.dll (if this is meant by "JdbcOdbc library") is in the DLL search path, I even copied it to the current directory. What's going wrong? Thanks for any help.

Sidi

JdbcOdbcDriver class loaded
DriverManager.initialize: jdbc.drivers = null
JDBC DriverManager initialized
registerDriver: driver[className=sun.jdbc.odbc.JdbcOdbcDriver,context=null,sun.jdbc.odbc.JdbcOdbcDriver@13]
DriverManager.getConnection("jdbc:odbc:JDBCAccess")
    trying driver[className=sun.jdbc.odbc.JdbcOdbcDriver,context=null,sun.jdbc.odbc.JdbcOdbcDriver@13]
*Driver.connect (jdbc:odbc:JDBCAccess)
JDBC to ODBC Bridge: Checking security
No SecurityManager present, assuming trusted application/applet
JDBC to ODBC Bridge 1.2001
Current Date/Time: Wed Jan 06 19:07:34 GMT+01:00 1999
Loading JdbcOdbc library
Unable to load JdbcOdbc library
java.sql.SQLException: Unable to load JdbcOdbc library
      at sun/jdbc/odbc/JdbcOdbc.<init> (JdbcOdbc.java:88)
      at sun/jdbc/odbc/JdbcOdbcDriver.initialize (JdbcOdbcDriver.java:315)
      at sun/jdbc/odbc/JdbcOdbcDriver.connect (JdbcOdbcDriver.java:153)
      at java/sql/DriverManager.getConnection (DriverManager.java:91)
      at java/sql/DriverManager.getConnection (DriverManager.java:0)

0
Comment
Question by:sidi010799
  • 2
4 Comments
 

Expert Comment

by:T38Jet
ID: 1230616
I had that same problem and "fixed" it. But after I got Java to connect to the Access database, my machine would crash every time I tried to open the same database with Access again. I finally had to "wipe-and-load" my machine to get rid of the JDBC stuff.

But if I remember correctly, it had something to do with the connection string and/or a DSN for the database.
0
 
LVL 16

Accepted Solution

by:
heyhey_ earned 100 total points
ID: 1230617
the code snippet that throws the exception (from sun.jdbc.JdbcOdbc.class) is

    JdbcOdbcObject.trace("JDBC to ODBC Bridge " + 1 + "." + s1);
    JdbcOdbcObject.trace("Current Date/Time: " + date.toString());
    JdbcOdbcObject.trace("Loading " + s + "JdbcOdbc library");
    }
    System.loadLibrary(s + "JdbcOdbc");
    return;
    }
    catch(UnsatisfiedLinkError ex) {}
    if(JdbcOdbcObject.isTracing())
    JdbcOdbcObject.trace("Unable to load " + s + "JdbcOdbc library");
    throw new SQLException("Unable to load " + s + "JdbcOdbc library");
    }

as you can see the exception is thrown from this line:
  System.loadLibrary(s + "JdbcOdbc");
(where s is a 'native prefix' - as you can see in the trace s is empty string)

'public static void loadLibrary(String libname)
Loads the system library specified by the libname argument.
The manner in which a library name is mapped to the actual system library
is system dependent.

Parameters:
libname - the name of the library.
Throws: SecurityException
if the current thread cannot load the specified dynamic library.
Throws: UnsatisfiedLinkError
if the library does not exist.'

the exception UnsatisfiedLinkError so there are some problems with the native library loading.
if you are Windows user, this is (probably) JDBCODBC.DLL

so this sure is some kind of installation problem (Windows installation / or JDK installation).
(JDBCODBC.DLL uses several other - probably system - DLLs)

Note: I have never experinced problems with JdbcOdbc bridge in JDK1.1.

If you have more questions, please post them here.

best regards
  heyhey
 
P.S.
At the moment I have installed version of JDK1.1.6
and I have two DLL files in the jdk\bin directory (which is in my path)
e:\java\jdk1.1.6\bin>dir jdbc*.*

 Directory of  E:\java\jdk1.1.6\bin\jdbc*.*
 4-16-98   6:53          21,504  JdbcOdbc.dll
 4-16-98   6:54          22,016  JdbcOdbc_g.dll
         43,520 bytes in 2 files and 0 dirs    65,536 bytes allocated


0
 
LVL 16

Expert Comment

by:heyhey_
ID: 1230618
btw - what is your platform, jdk version, etc.
0
 

Author Comment

by:sidi010799
ID: 1230619
Thanks for the answers. Seeing the code snippet where the exception is thrown was definitely helpful to get the details. As I had stated in my question, though, I had put the DLL about everywhere the program might possibly look for it. I have solved the problem in the meantime: I was using MS J++ 6.0 to compile the code (sorry for not mentioning this in the question) and then running the program from the command line using MS' jview VM. I used jview because using the Sun VM (JDK1.2) gave me an error right at the beginning. After a while I got to the idea to compile the whole program using the JDK1.2 javac command and - wow - the library loaded correctly. Looks like another example of incompatibility between the different VMs.
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question