[Fixed] java.lang.classnotfoundexception: sun.jdbc.odbc.jdbcodbcdriver

In this post, we will see how to resolve java.lang.classnotfoundexception: sun.jdbc.odbc.jdbcodbcdriver exception in java.

Problem: java.lang.classnotfoundexception: sun.jdbc.odbc.jdbcodbcdriver

This exeception comes in Java 8 because sun.jdbc.odbc.jdbcodbcdriver has been removed from JDK and JRE. This class is used to connect database using Object database connectivity driver such as Microsoft access.

Since Java 8 does not support jdbc odbc bridge, you need to use some other alterantive solutions to resolve this issue.

Solution 1 : Using UCanAccess jars

You can use UCanAccess jars to resolve this issue.

Here is the dependencies you can put in your pom.xml.

Maven will add all other required dependencies for you.

Here is example code to connect using UCanAccess libraries.

Please note that if you are working with large databse and using defualt memory setting, it is recommended to use xmx and xms parameter to allocate sufficient memory, otherwise you have to set drive’s memory property to false as below

Solution 2 : Revert Java version to 7 or before

If you are not using features of Java 8, then you can revert your java version to 7 and it will work fine.

That’s all about how to resolve java.lang.classnotfoundexception: sun.jdbc.odbc.jdbcodbcdriver exception in java.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.