The JDBC/ODBC driver is the type 1 driver it is also known as JDBC-ODBC bridge. It is ODBC driver to connect the database that convert the JDBC calls to ODBC function calls. Type 1 driver is fully platform dependent and use the native libraries of operating system. The ODBC driver must be installed in operating system. The Sun Microsystem provide JDBC-ODBC driver name as sun.jdbc.odbc.JdbcOdbcDriver but Oracle's JDBC-ODBC Bridge was removed in Java 8 for following reasons:-
Disadvantages
- Performance issue the calls have to go through the JDBC bridge to the ODBC driver so it is slower than other types of drivers.
- The ODBC driver must be installed on the client machine.
- Creating Problem to run the applets, because the ODBC driver needs to be installed on the client.
In Java 8 we can read and write to Access databases without using ODBC with the help of UcanAccess driver. Java 8 provide an alternative option in place of JDBC-ODBC bridge because you not need to install ODBC in your system and compatible with both windows and non windows environments . UCanAccess is a pure Java JDBC driver which allow us to read from and write to Access databases without using ODBC. It uses at least two dependencies jackcess-2.1.2.jar and hsqldb.jar.
To connect with database(access,open office etc.) you can code like this:-
Connection conn=DriverManager.getConnection("jdbc:ucanaccess://C:/files/emp.accdb");
Statement s = conn.createStatement();
ResultSet rs = s.executeQuery("SELECT empname FROM employees");
while (rs.next()) {
System.out.println(rs.getString(1));
}
2 Comment(s)