Solved

Using JDBC-ODBC bridge

Posted on 1999-01-07
4
865 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Weekend adv creator 3 39
VB Script to add site to Java Exception List 4 80
SHA2 certs for IIS AND Java? 2 97
Chrome and Firefox Java 5 34
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

831 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