Solved

Using JDBC-ODBC bridge

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
split53 challenge 7 77
Requested array size exceeds VM limit 3 84
Groovy:unable to resolve class error 2 66
thymeleaf natural templating vs JSP 2 65
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

929 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now