Solved

Using JDBC-ODBC bridge

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This video teaches viewers about errors in exception handling.

747 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