Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removal of JDBC ODBC bridge in java 8

Starting with Java 8, the JDBC-ODBC Bridge will no longer be included with the JDK.

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // classNotFoundException is thrown 

Is there any other solution connecting JDBC-ODBC Bridge?

like image 898
Karthik Avatar asked Jan 09 '13 05:01

Karthik


People also ask

What is JDBC ODBC bridge Why do we need it?

The JDBC-ODBC Bridge allows applications written in the Java programming language to use the JDBC API with many existing ODBC drivers. The Bridge is itself a driver based on JDBC technology ("JDBC driver") that is defined in the class sun.

Which JDBC driver is JDBC ODBC bridge driver?

The JDBC type 1 driver, also known as the JDBC-ODBC bridge, is a database driver implementation that employs the ODBC driver to connect to the database. The driver converts JDBC method calls into ODBC function calls.

Is JDBC built on ODBC?

No. ODBC stands for Open Database Connectivity which literally means that it is compatible with all types of languages such as C, C++, Java, etc. JDBC Stands for Java database connectivity i.e only compatible with java language. ODBC was introduced by Microsoft prior to JDBC in 1992.

Is the JDBC ODBC bridge single threaded?

No. The JDBC-ODBC Bridge does not support concurrent access from different threads. The JDBC-ODBC Bridge uses synchronized methods to serialize all of the calls that it makes to ODBC. Multi-threaded Java programs may use the Bridge, but they won't get the advantages of multi-threading.


1 Answers

We can still use JDBC-ODBC Bridge in java 8 too, just follow this simple recipe:

  1. Download a JDK 7 or JRE 7.
  2. Goto JRE\lib folder and find the rt.jar
  3. Unzip it (if you have WinRAR or 7zip installed) or you can rename it to rt.zip and unzip it.
  4. Copy sun\jdbc and sun\security\action folders out, keep the folder structure. i.e., you should have the folder structure like below:

    Sun --> Security --> Action     --> JDBC 
  5. Open a CMD window. Go to the parent folder of Sun folder. Run the command: jar -cvf jdbc.jar sun

  6. The above command will create a file named jdbc.jar
  7. Copy JDBC.jar to your JDK8 or JRE8 lib folder. If that doesn't work try the lib\ext folder.
  8. Copy jdbcodbc.dll from JRE\bin of your JRE 7 installation to JRE\bin of your JRE 8 installation.
  9. Restart your JVM.

How to enable JDBC-ODBC bridge for JDK 8

like image 180
frhack Avatar answered Sep 24 '22 14:09

frhack