Sun.jdbc.odbc.jdbcodbcdriver For Ms Access

 admin

This article demostrates how to access MS Access databases from Java. (' sun.jdbc.odbc.JdbcOdbcDriver'); Open the MS-Access database file in the application space. Java.lang.classnotfoundexception sun.jdbc.odbc.jdbcodbcdriver. To MS Access, we need type 1 JDBC.

  1. Give More Feedback
  2. See More On Stackoverflow

Q: Two questions:. How do you connect to a Microsoft Access-based database (in a Windows system) using JDBC?. In Class.forName(.) and DriverManager.getConnection(.), what driver and URL should you use? A: There are two techniques available for connecting to a data source using JDBC. First, if your program will talk to an ODBC data source, you can use the JDBC-ODBC bridge included with your JDK.

In the case of Sun, you would use sun.jdbc.odbc.JbdcOdbcDriver. Specifically, using Class.forName: Class.forName('sun.jdbc.odbc.JdbcOdbcDriver'); or the command line: java -Djdbc.drivers=sun.jdbc.odbc.JdbcOdbcDriver Second, you can connect to your data source through a third-party, vendor-specific bridge. In the case of a third party driver, you simply substitute that driver for the JDBC-ODBC bridge driver. See the section below for a link to Sun's database of available drivers.

Once you have a driver loaded and your data source set up, getting a connection is a simple matter of feeding the correct URL, name, and password to the getConnection method. A JDBC URL takes the following form: jdbc:: In the case of Microsoft Access and the ODBC bridge, it would take the form: jdbc:odbc: where is the name that you gave the data source when you set it up. As an aside for those using other drivers, is the name of the connectivity mechanism used by the driver. In my answer, I've assumed quite a bit of JDBC knowledge. If you're completely new to JDBC, or even if you just need to brush up your skills a bit, head on over to the JDBC Short Course (see ), an excellent training course that will get you up to speed quickly. Tony Sintes is a principal consultant at BroadVision.

Sun.jdbc.odbc.jdbcodbcdriver For Ms Access

Tony, a Sun-certified Java 1.1 programmer and Java 2 developer, has worked with Java since 1997.

Java.lang.classnotfoundexception sun.jdbc.odbc.jdbcodbcdriver exception comes in Java 8 because it has removed the JDBC ODBC bridge driver class 'sun.jdbc.odbc.jdbcodbcdriver' from JDK and JRE. This class is required to connect any database using Object database connectivity driver e.g. Microsoft Access, but unfortunately you cannot use it from JDK 8 onward. In order to solve this error, just use Jackcess library or a commercial driver like HXTT.

Normally, in pre Java 8 world, java.lang.classnotfoundexception sun.jdbc.odbc.jdbcodbcdriver error comes when you try to connect to Microsoft Access database from Java using JDBC and JDBC ODBC bridge driver is not available in classpath. If you remember, In order to open SQL connection to database, first step is to load and register the driver. In order to load driver, we use Class.forName('sun.jdbc.odbc.JdbcOdbcDriver'); and this method throws java.lang.classnotfoundexception sun.jdbc.odbc.jdbcodbcdriver, if ClassLoader is not able to find the requested class ( sun.jdbc.odbc.JdbcOdbcDriver ) in CLASSPATH. In order to connect to MS Access, we need, also known as JDBC ODBC bridge driver and the class in question, JdbcOdbcDriver is driver implementation to connect to Open database connectivity driver installed in machine. Just remember that sun.jdbc.odbc.JdbcOdbcDriver is a standard class from JDK API and it doesn't come with any external JAR like other vendor database's JDBC drivers e.g.

JDBC driver to connect Oracle database comes on and MySQL driver comes in. JdbcOdbcDriver class is present in, which is always included in Classpath, as this JAR file is part of the JRE.

Give More Feedback

Many newbie in Java programming prefer to connect to MS Access database from Java then bigger database like Oracle, SQL Server or MySQL. Even I have done the same when I first started learning JDBC, main reason for that was MS ACCESS comes as part of Microsoft Office and was available in my machine. I didn't have to go with pain involved on installing Oracle, SQL Server or MySQL database, sometime even you don't even have administrator access in your machine to do that. BTW, there are several disadvantage of using JDBC ODBC Bridge driver, first it require ODBC driver to be installed in your machine, second it makes your code platform dependent. Using is best way to connect commercial database from Java programs.

See More On Stackoverflow

Almost all major database vendor provides type 4 JDBC driver now days, so its just matter of finding right version and dropping that JAR in classpath. Java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver in Java 8 JDBC-ODBC bridge driver has been marked as 'don't use' for the last decade or so.

It was present in Java 7 release but removed from Java 8 release onward. It might also not be available on non-Windows JVMs, as it makes no sense to have an ODBC-JDBC bridge driver on platforms on which ODBC does not exist e.g. Linux or Mac OS.

Comments are closed.