Thursday, January 17, 2008

Data Base Connectivity in java

Database connectivity in java

To develop application that communicated with database to perform following task:
• Store and update the data in data base.
• Retrieve the data stored is data base and present it to users in proper format.

Sun Micro system included API as part of J2SDK to develop java application that can communicate with the database

JDBC Architecture






Java application cannot directly communicate with database to submit data and retrieve the result of the query. This is because database can only interpret SQL statement not java language statement. So, JDBC Architecture provides mechanism to translate java statement to SQL statement.

JDBC Architecture classified into two layers:
• JDBC Application layer:
Java application uses java API to interact with JDBC Drivers.
JDBC driver is software that a java application uses to access data base. JDBC driver manager of JDBC API connects the java application to the Driver.

• JDBC Driver Layer:
Act as interface b\w a java application and database. This layer contains Driver Such as SQL driver or Oracle driver which enables connectivity to the data base.

How JDBC Driver Layer works:
1. A driver sends request of java application to database.
2. After processing the request, database sends the response back to driver.
3. Driver translates response to the JDBC API.
4. JDBC API forwards it to the java application.

JDBC Drivers

Java support four types of Drivers
• JDBC-ODBC Bridge Driver
• Native API Partly-java driver
• JDBC-Net Pure-Java driver
• Native Protocol Pure-Java driver

No comments: