This section contains the detail about the Architecture of JDBC in java.
Architecture of JDBC
JDBC architecture can be classified in 2 broad categories:-
1. JDBC API
2. Types of JDBC Drivers
JDBC APIJDBC programming interface is found in "java.sql" and "javax.sql" packages. Given below some classes and interfaces which support connectivity between interface and database :-
1. DriverManager :-"Driver Manger" Manages all the Drivers found in JDBC environment, load the most appropriate driver for connectivity.
2. Connection :-Connection class creates objects which represents connection and it's object also helps in creating object of Statement, PreparedStatement and CallableStatement classes.
3. Statement :-Statement object is used to execute query and also store it's value to "Resultset" object.
4. PreparedStatement:-It can be used in place of "Statement", PreparedStatement's performance is high as compared to "Statement" class, represents a precompiled SQL statement .
5. Callable Statement:-Callable statement support stored procedure of RDBMS' ,using it's object you can execute stored procedure of database application.
6. ResultSet :-Resultset object is used to store the result retrieve from database using "Statement" or "PreparedStatement" , etc
7. SQLException:- SqlException class is used to represent error or warning during access from database or during connectivity.
JDBC Driver's Type
JDBC Driver can be broadly categorized into 4 categories--
JDBC-ODBC Bridge Driver(Type-1)
Converted the query of JDBC Driver into the ODBC query, which in return pass the data. JDBC-ODBC is native code not written in java.The connection occurs as follows -- Client -> JDBC Driver -> ODBC Driver -> Database .A type-1 driver is easy to install and handle. Extra channels in between database and application made performance overhead. Needs to be installed on client machine. Not suitable for applet , due to the installation at clients end.
Native-API Type-2 Driver
The type 2 driver need libraries installed at client site. For example, we need "mysqlconnector.jar" to be copied in library of java kit. It is not written in java entirely because the non-java interface have the direct access to database. Type 2 driver has additional functionality and better performance than Type 1.Has faster performance than type 1,3 &4,since it has separate code for native APIS . Library needs to be installed on the client machine ..Due to the client side software demand, it can't be used for web based application. It is platform dependent. It doesn't support "Applets".
Network-Protocol Type-3 driverIt has a 3-tier architecture. It can interact with multiple database of different environment. The JDBC Client driver written in java, communicates with a middleware-net-server using a database independent protocol, and then this net server translates this request into database commands for that database. The connection occurs as follows--Client -> JDBC Driver -> Middleware-Net Server -> Any Database. The client driver to middleware communication is database independent. Can be used in internet since there is no client side software needed. Needs specific coding for different database at middleware. Due to extra layer in middle can result in time-delay.
Native Protocol Type-4 Driver
Also known as Direct to Database Pure Java Driver .It is entirely in java. It interacts directly with database generally through socket connection. It is platform independent. It directly coverts driver calls into database protocol calls. Improved performance because no intermediate translator like JDBC or middleware server. All the connection is managed by JVM, so debugging is easier.
[ 0 ] Comments