JDBC Introduction

JDBC is an acronym Java Data Base Connectivity. JDBC helps us to connect to the database and execute SQL statements against the database. First let us know the basics of JDBC. Why we are using Java instead of other languages like C language.

Can't we access the database using the C program?

          Yes, we can access the database using the C program. In-order to work with Data Base we need a database server software. When we download this software, it consists of two software's. They are 1) Database Server Software & 2) Database Client Software. When we install the software  these two softwares get installed into our computer. Every Database server uses its own protocol. For example, Oracle DB server uses 'thin' protocol for its database access. These protocols are not public, so we are not aware of that protocols. Without knowing the protocols one cannot communicate with DB server. To resolve this problem Oracle has released a set of functions called OCI functions(Oracle Call Interface functions). These functions are written in C language. The internal code of these functions communicate with DB server, even if we are not aware of protocol. Originally they are called as CI funcitons, but since they are developed by oracle, they are named as OCI. Not only Oracle, many other companies also released CI functions(for example MySQL as MCI functions, Sybase as SCI functions etc..,). These CI functions are also called as 'DB server Native Functions'. The following shows the architecture of the C program to communicate with Database.
jdbc architecture
fig: Architecture of C program to communicate with DB.
Well now let us assume that we have developed a C program that communicate with Oracle DB server. Note that this program can communicate only with Oracle DB server. It is not able to communicate with MySQL DB server. The reason why this program cannot communicate with other DB servers is, every DB server uses their own protocol and CI functions which are different form the functions we used in the program.

Note: The disadvantage with C program is, at a time it can communicate with only one DB server.

To resolve this problem Microsoft introduced an API called "ODBC API". Using this API we can make a C program to communicate with any DB server. This API consists of the functions which can communicate with all the DB servers.  As Microsoft released an API any one can implement it. This implementation is known as "ODBC Driver Software". Once if any company released a Driver software, it can be used to communicate with any DB server.
odbc
Fig: ODBC API released by Microsoft, implemented by different companies and used to access any DB server. 

Note: Another disadvantage of C program is that, it need more lines of code when compared to JDBC code. So, we prefer JDBC to C program.

Finally, now let us know the definition of JDBC.

JDBC Definition:

         JDBC is an API which is used to develop a java program that communicates with any Data Base server without changing the code.


2 comments:

  1. same material is provided by InetSolv classes in Hyderabad by Sumanth Sir.. It doesn't differ a single word..

    ReplyDelete
  2. Hey, would you mind if I share your blog with my twitter group? There’s a lot of folks that I think would enjoy your content. Please let me know. Thank you.
    Java Training in Chennai | J2EE Training in Chennai | Advanced Java Training in Chennai | Core Java Training in Chennai | Java Training institute in Chennai

    ReplyDelete