JDBC-ODBC Connection is a JDBC driver that translates the operation in JDBC into ODBC. For ODBC,it is a normal java application program. This bridge provides JDBC for database in which an ODBC driver is available. The bridge is represented as sun.jdbc.odbc.The Java contain a defined package and its library to access ODBC.
Understand with Example
In this Tutorial we help you in explaining JDBC Odbc Connection in Java. The code explains you a how creation and closing of connection is done. For this code we have a JdbcOdbc Connection class. The class contains a main method, that include a list of steps as follow -
Loading a driver is the first step to be done inside the try block of main method ( ) by calling a Class.forName ( ),this class accept a "sun.jdbc.odbc.jdbcodbc Driver" as argument.
DriverManager.getConnection ( ) : This establish or built a connection between url and emp table in the database.
The print print the "New Connection Create..."..The Connection object call a close ( ),return you the connection is closed. The println show the "Connection closed"
In case the exception exists in a try block, the subsequent catch block check and handle the exception.JdbcOdbcConnection.java
New Connection Create .... Connection closed
Liked it! Share this Tutorial