Professional Documents
Culture Documents
Chapter - V
JDBC
Facebook
Frontend
Facebook.com
Creating account by clicking Sing Up
1. Username ___________
2. Password _________
3. Submit
4. Facebook request to create a new account 🡪 registration details will
get it store within database.
Database
Java, servlet, HTTP
MySQL, Acccess,
form, JSP, etc….
JDBC fill the gap Oracle, hadoop,
Between the frontend Sqllite etc.
And the backend
frontend backen
d
CAR :
OLA Book :
BUS :
Train:
Hire Driver
• ODBC is a C language API, not a Java (object-oriented and C is not) API. C uses
pointers and other "dangerous" programming constructs that Java does not support. A Java
version of ODBC would require a significant rewrite of the ODBC API.
• ODBC drivers must be installed on client machines. This means that applet access to
databases would be constrained by the requirement to download and install a JDBC driver.
A pure solution allows JDBC drivers to be automatically downloaded and installed along
with applet. This greatly simplifies database access for applet users.
Disadvantages
1. Since the Bridge driver is not written fully in Java, Type 1 drivers
are not portable.
2. A performance issue is seen as a JDBC call goes through the
bridge to the ODBC driver, then to the database, and this applies
even in the reverse process. They are the slowest of all driver types.
3. The client system requires the ODBC Installation to use the
driver.
4. Not good for the Web.
Disadvantage
1. Native API must be installed in the Client System and hence type 2
drivers cannot be used for the Internet.
2. Like Type 1 drivers, it’s not written in Java Language which forms a
portability issue.
3. If we change the Database we have to change the native api as it is
specific to a database
4. Mostly obsolete now
5. Usually not thread safe.
Disadvantage
It requires another server application to install and maintain. Traversing the
recordset may take longer, since the data comes through the backend server.
Disadvantage
1. With type 4 drivers, the user needs a different driver for each
database.
rt
ql
ge
import java.sql.*;
DriverManager .getConnection();
con.close();
s,.close();
Rs.close();
DriverManager:
This class manages a list of database drivers. Matches connection
requests from the java application with the proper database driver
using communication sub protocol. The first driver that recognizes a
certain sub protocol under JDBC will be used to establish a database
Connection.
Driver:
This interface handles the communications with the database server.
You will interact directly with Driver objects very rarely. Instead, you
use DriverManager objects, which manages objects of this type. It
also abstracts the details associated with working with Driver objects
Statement :
You use objects created from this interface to submit the SQL statements to the
database. Some derived interfaces accept parameters in addition to executing
stored procedures.
ResultSet:
These objects hold data retrieved from a database after you execute an SQL query
using Statement objects. It acts as an iterator to allow you to move through its data.
SQLException:
This class handles any errors that occur in a database application.