Bachelor in Computer Application

JAVA DATABASE CONNECTIVITY

Java DataBase Connectivity

JDBC stands for Java Database Connectivity. JDBC is a Java API to connect and execute the query with the database. It is a part of JavaSE (Java Standard Edition). JDBC API uses JDBC drivers to connect with the database. There are four types of JDBC drivers: o JDBC-ODBC Bridge Driver, o Native Driver, o Network Protocol Driver, and o Thin Driver

We can use JDBC API to access tabular data stored in any relational database. By the help of JDBC API, we can save, update, delete and fetch data from the database. It is like Open Database Connectivity (ODBC) provided by Microsoft.
                                        fig: JDBC 


We can use JDBC API to handle database using Java program and can perform the following activities:
1. Connect to the database
2. Execute queries and update statements to the database
3. Retrieve the result received from the database.

JDBC-ODBC Bridge 

Microsoft's ODBC (Open Database Connectivity) is the most commonly used driver to connect to the database as it can connect to almost all databases on most of the platforms. However, ODBC uses the concept of pointers and other constructs that are not supported by Java.

Therefore, JDBC-ODBC bridge driver was developed which translates the JDBC API to the ODBC API and vice versa. This bridge acts as interface that enables all DBMS which support ODBC (Open Data Base Connectivity) to interact with Java Applications. JDBC-ODBC bridge is implemented as a class file and a native library. The name of the class file is JdbcOdbc.class.

Figure shows the JDBC application architecture in which a front-end application uses JDBCAPI for interacting with JDBC Driver Manager. Here, JDBC Driver Manager is the backbone of JDBC architecture. It acts as interface that connects a Java application to the driver specified in the Java program. Next, is the JDBC-ODBC bridge which helps the JDBC to access ODBC data sources.
Making ODBC Connection 

//JDBC-ODBC Bridge (But removed from Java 8)   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");  String url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb,                 *.accdb)};DBQ=" + "D:\\mydb.accdb";  Connection conn = DriverManager.getConnection(url);

Example :1



Post a Comment

0 Comments