0% found this document useful (0 votes)
2 views12 pages

Java U5 C

The document provides an overview of Database Connectivity with Java using the JDBC API, detailing its architecture, driver types, and configuration. It explains how Java applications can interact with databases to execute SQL statements, manage connections, and handle data. Additionally, it includes tutorials for JDBC configuration and database connection management.

Uploaded by

preciouslife1393
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views12 pages

Java U5 C

The document provides an overview of Database Connectivity with Java using the JDBC API, detailing its architecture, driver types, and configuration. It explains how Java applications can interact with databases to execute SQL statements, manage connections, and handle data. Additionally, it includes tutorials for JDBC configuration and database connection management.

Uploaded by

preciouslife1393
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Database Connectivity with Java

Prativa Nyaupane
Outline
- JDBC Architecture
- JDBC Driver Types and Configuration
- Managing Connections and Statements
- Result Sets and Exception Handling
- DDL and DML Operations
- SQL Injection and Prepared Statements
- Row Sets and Transactions
- SQL Escapes
Introduction
- A database is an organized collection of data.
- Database Management System provides mechanisms for storing, retrieving and
modifying data for many users.
- DBMS allow for the access and storage of data without concern for the internal
representation of data.
- Relational DBMS stores data in tables. Tables are composed of rows and columns.
- Some popular RDBMSs are Microsoft SQL Server, Oracle, Sybase, PostgreSQL and
MySQL.
- The JAVA API is an interface which consists of description of all the characteristics of
the application. It is just a set of procedures that carry out specific tasks and make
development of applications easier.
JDBC API
- Java programs communicate with database and manipulate their data using
the Java Database Connectivity(JDBC) API.
- It allows any java program to execute SQL(Structured Query Language)
statements and retrieve results, modify data and delete data.
- The java.sql package contains classes and interfaces for JDBC API

Backend
Java application JDBC
database

Fig: JDBC Link with Java Application and Database


JDBC API
- Java provides following APIs with respect to database:
- Defining the DriverManager for respective database drivers.
- Establishing a connection to the database
- Creating statements.
- Executing queries in the database
- Display and update of the resultant tuples.

JDBC simplifies database interaction by providing a set of interfaces for seamless


portability across different databases.
JDBC API

● The JDBC API (Application Programming Interface) is a set of Java classes and

interfaces that define the standard methods and behaviors for database

connectivity.

● It allows Java applications to execute SQL statements, retrieve and

manipulate data, and manage database connections.

● The JDBC API provides a common interface regardless of the specific

database being used, enabling portability and flexibility.


JDBC Architecture Contd..
JDBC Driver Types and Configuration
● A database driver is a software component that acts as an interface between the

Java application and a specific database management system (DBMS).

● It allows Java applications to communicate with the database by translating the

JDBC calls into the appropriate DBMS-specific commands.

● Each database vendor provides its own database driver, which needs to be

included in the Java application's classpath to establish a connection with that

specific database.
Java Native Driver
● A Java Native Driver is a JDBC driver that is specifically designed to work
with a particular database management system (DBMS) using native
protocols.

● It is implemented in Java and provides direct communication between the


Java application and the DBMS without the need for any intermediate
layers or bridges.

● Java Native Drivers offer better performance and platform independence


compared to JDBC-ODBC bridges.
Java Native Driver
Java Native Driver
● Advantage:
○ performance upgraded than JDBC-ODBC bridge driver.

● Disadvantage:

○ The Native driver needs to be installed on the each client


machine.

○ The Vendor client library needs to be installed on client


machine.
Tutorial
- Database Connectivity with JDBC: Step-by-step tutorials on JDBC
configuration, database connection management, executing SQL queries
and handling result sets.

You might also like