SlideShare a Scribd company logo
JDBC
(Java Database Connectivity)
Introduction
•It is an API (Application Programming Interface)
•Used to connect JAVA application with database
•Interact with different types of databases like,
MS Access, MySQL, Oracle, SQL Server,
PostgreSQL, Sybase
07/01/16 2
JDBC Driver
•Type-1 Driver ( JDBC-ODBC Bridge)
•Type-2 Driver (Native-API Partly Java Driver / Partly Java)
•Type-3 Driver (Network Protocol Driver / Pure Java to Middleware)
•Type-4 Driver (Thin Driver / Pure Java Direct to Database)
07/01/16 3
Type-1 Driver ( JDBC-ODBC Bridge)
•Act as a bridge between JDBC
and other database connectivity
mechanism (ODBC)
•Converts JDBC calls into ODBC
calls and redirects the request
to ODBC driver
•Sun provides a JDBC-ODBC
Bridge Driver
07/01/16 4
Type-1 Driver ( JDBC-ODBC Bridge) cont…
•Advantages
Easy to use
Allow easy connectivity to all database supported by the ODBC
Driver
•Disadvantages
Slow execution time
Dependent on ODBC Driver
Uses Java JNI (Native Interface) to make ODBC call
07/01/16 5
Type-2 Driver (Native-API Partly Java Driver /
Partly Java)
•Converts JDBC calls into calls to the
client
API for that database
•Client 
JDBC Driver 
Vendor Client DB Library

DB
07/01/16 6
Type-2 Driver (Native-API Partly Java Driver /
Partly Java) cont…
•Advantages
Better performance than Type-1 because no JDBC to ODBC
translation is needed.
•Disadvantages
Vendor client library needs to be installed on the client machine.
Can not be used in web-based application due the client side s/w
needed.
Not all database have a client side library.
07/01/16 7
Type-3 Driver (Network Protocol Driver / Pure
Java to Middleware)
•Follow three tier communication
approach
•Can interface to multiple databases
•Client 
JDBC Driver 
Middleware-Net Server 
Any Database
07/01/16 8
Type-3 Driver (Network Protocol Driver / Pure
Java to Middleware) cont…
•Advantages
Does not require any native library to be installed.
Database Independency
Provide facility to switch over from one database to another
database
•Disadvantages
Slow due to increase number of network call
07/01/16 9
Type-4 Driver (Thin Driver / Pure Java Direct
to Database)
•Interact directly with database
•Does not require any native
database
library
•Called pure Java Driver
•Also known as Thin Driver
07/01/16 10
Type-4 Driver (Thin Driver / Pure Java Direct
to Database)
•Advantages
Does not require any native library
Does not require any Middleware server
Better Performance than other driver
•Disadvantages
Slow due to increase number of n/w call
At client side, a separate driver is needed for each database
07/01/16 11
Classes / Interfaces (java.sql package)
07/01/16 12
Connection Interface
Method Description
void close() This method frees the connection object’s database and other JDBC
resources
void commit() This method makes all the changes made since the last commit or
rollback. It throws SQLException
boolean isClosed() This method returns “true” if the connection is close else returns
“false”
void rollback() This method undoes all changes made to the database
Statement createStatement() This method creates a Statement object for sending SQL statements
to the database. throws SQLException
CallableStatement
prepareCall(String s)
This method creates a CallableStatement object for calling stored
procedures. It throws SQLException
PreparedStatement
prepareStatement(String s)
This method creates a PreparedStatement object for sending SQL
statements with or without IN parameter. It throws SQLException.
07/01/16 13
Statement Interface
Method Description
void close() this method releases the statement object’s database and JDBC
resources
boolean execute(String s) This method executes the SQL statement specified by s.
ResultSet executeQuery(String s) This method executes the SQL statement specified by s and returns
the ResultSet object
int executeUpdate(String s) This method executes the SQL statement specified by s. These
statements may be INSERT, UPDATE or DELETE
int getMaxRows() This method returns the maximum number of rows that are
generated by the executeQuery() method
ResultSet getResultSet() This method retrieves the ResultSet generated by the execute()
method
07/01/16 14

More Related Content

PPSX
JDBC: java DataBase connectivity
PPT
MySql slides (ppt)
PPT
Jsp ppt
DOC
jdbc document
PDF
J2EE Introduction
PPT
Oops ppt
PPT
JDBC Architecture and Drivers
JDBC: java DataBase connectivity
MySql slides (ppt)
Jsp ppt
jdbc document
J2EE Introduction
Oops ppt
JDBC Architecture and Drivers

What's hot (20)

PPS
Jdbc architecture and driver types ppt
PPT
JDBC – Java Database Connectivity
PPT
MYSQL.ppt
PPTX
Core java complete ppt(note)
PPT
Java collections concept
PPTX
Introduction to Java -unit-1
PPTX
Servlets
PPT
Java interfaces
PPTX
PPTX
oops concept in java | object oriented programming in java
PDF
Overview Of JDBC
PPTX
A brief introduction to SQLite PPT
PPTX
PPTX
Angularjs PPT
PDF
Chapter 5 Database Transaction Management
PPTX
Important features of java
PPT
C#.NET
PPTX
Java Server Pages(jsp)
PDF
JDBC : Java Database Connectivity
Jdbc architecture and driver types ppt
JDBC – Java Database Connectivity
MYSQL.ppt
Core java complete ppt(note)
Java collections concept
Introduction to Java -unit-1
Servlets
Java interfaces
oops concept in java | object oriented programming in java
Overview Of JDBC
A brief introduction to SQLite PPT
Angularjs PPT
Chapter 5 Database Transaction Management
Important features of java
C#.NET
Java Server Pages(jsp)
JDBC : Java Database Connectivity
Ad

Viewers also liked (20)

PPTX
Java Beans
PPTX
Presentation15 parse xml
PPTX
Presentation14 audio play
PPTX
Presentation11 sq lite
PPTX
Presentation8 silder switch_progress
PPTX
Presentation4 date picker
PPTX
Hadoop installation
PPTX
java code and document security
PPT
Java Generics for Dummies
PDF
PPTX
java drag and drop and data transfer
PPTX
Java Generics
PPT
Java Generics
PDF
Event handling
PPT
Bean Intro
PPTX
Java bean
PDF
Collections In Java
PDF
Java beans
PPTX
Javabeans
Java Beans
Presentation15 parse xml
Presentation14 audio play
Presentation11 sq lite
Presentation8 silder switch_progress
Presentation4 date picker
Hadoop installation
java code and document security
Java Generics for Dummies
java drag and drop and data transfer
Java Generics
Java Generics
Event handling
Bean Intro
Java bean
Collections In Java
Java beans
Javabeans
Ad

Similar to java Jdbc (20)

PDF
Java unit 14
PDF
Unit 5.pdf
PPTX
java.pptx
PPT
Java database connectivity
PPT
Java database connectivity
PPTX
Core jdbc basics
PPTX
Jdbc introduction
PPT
JDBC java database connectivity with dbms
PPT
PPTX
Jdbc driver types
PDF
jdbc
PPTX
Java Database Connectivity (JDBC)
PPT
4-INTERDUCATION TO JDBC-2019.ppt
PPT
JDBC java for learning java for learn.ppt
PPT
Jdbc complete
PDF
Java and Database - Interacting with database
PDF
unit8_jdbc.pdf mysql and java jdbc connection
PPTX
Jdbc
Java unit 14
Unit 5.pdf
java.pptx
Java database connectivity
Java database connectivity
Core jdbc basics
Jdbc introduction
JDBC java database connectivity with dbms
Jdbc driver types
jdbc
Java Database Connectivity (JDBC)
4-INTERDUCATION TO JDBC-2019.ppt
JDBC java for learning java for learn.ppt
Jdbc complete
Java and Database - Interacting with database
unit8_jdbc.pdf mysql and java jdbc connection
Jdbc

More from Ankit Desai (11)

PPTX
Java RMI
PPT
java swing programming
PPT
Java Networking
PPT
PPTX
Presentation10 view navigation
PPTX
Presentation7 segment control
PPTX
Presentation6 ui image_view
PPTX
Presentation5 picker view
PPTX
Presentation3 actionsheet alertview
PPTX
Presentation1 password
PPTX
Presentation2 gesture control
Java RMI
java swing programming
Java Networking
Presentation10 view navigation
Presentation7 segment control
Presentation6 ui image_view
Presentation5 picker view
Presentation3 actionsheet alertview
Presentation1 password
Presentation2 gesture control

Recently uploaded (20)

PDF
Empathic Computing: Creating Shared Understanding
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Machine learning based COVID-19 study performance prediction
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Approach and Philosophy of On baking technology
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Encapsulation theory and applications.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
KodekX | Application Modernization Development
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
Empathic Computing: Creating Shared Understanding
Building Integrated photovoltaic BIPV_UPV.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
CIFDAQ's Market Insight: SEC Turns Pro Crypto
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Per capita expenditure prediction using model stacking based on satellite ima...
Machine learning based COVID-19 study performance prediction
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Approach and Philosophy of On baking technology
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Encapsulation theory and applications.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
KodekX | Application Modernization Development
Unlocking AI with Model Context Protocol (MCP)
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
The Rise and Fall of 3GPP – Time for a Sabbatical?

java Jdbc

  • 2. Introduction •It is an API (Application Programming Interface) •Used to connect JAVA application with database •Interact with different types of databases like, MS Access, MySQL, Oracle, SQL Server, PostgreSQL, Sybase 07/01/16 2
  • 3. JDBC Driver •Type-1 Driver ( JDBC-ODBC Bridge) •Type-2 Driver (Native-API Partly Java Driver / Partly Java) •Type-3 Driver (Network Protocol Driver / Pure Java to Middleware) •Type-4 Driver (Thin Driver / Pure Java Direct to Database) 07/01/16 3
  • 4. Type-1 Driver ( JDBC-ODBC Bridge) •Act as a bridge between JDBC and other database connectivity mechanism (ODBC) •Converts JDBC calls into ODBC calls and redirects the request to ODBC driver •Sun provides a JDBC-ODBC Bridge Driver 07/01/16 4
  • 5. Type-1 Driver ( JDBC-ODBC Bridge) cont… •Advantages Easy to use Allow easy connectivity to all database supported by the ODBC Driver •Disadvantages Slow execution time Dependent on ODBC Driver Uses Java JNI (Native Interface) to make ODBC call 07/01/16 5
  • 6. Type-2 Driver (Native-API Partly Java Driver / Partly Java) •Converts JDBC calls into calls to the client API for that database •Client  JDBC Driver  Vendor Client DB Library  DB 07/01/16 6
  • 7. Type-2 Driver (Native-API Partly Java Driver / Partly Java) cont… •Advantages Better performance than Type-1 because no JDBC to ODBC translation is needed. •Disadvantages Vendor client library needs to be installed on the client machine. Can not be used in web-based application due the client side s/w needed. Not all database have a client side library. 07/01/16 7
  • 8. Type-3 Driver (Network Protocol Driver / Pure Java to Middleware) •Follow three tier communication approach •Can interface to multiple databases •Client  JDBC Driver  Middleware-Net Server  Any Database 07/01/16 8
  • 9. Type-3 Driver (Network Protocol Driver / Pure Java to Middleware) cont… •Advantages Does not require any native library to be installed. Database Independency Provide facility to switch over from one database to another database •Disadvantages Slow due to increase number of network call 07/01/16 9
  • 10. Type-4 Driver (Thin Driver / Pure Java Direct to Database) •Interact directly with database •Does not require any native database library •Called pure Java Driver •Also known as Thin Driver 07/01/16 10
  • 11. Type-4 Driver (Thin Driver / Pure Java Direct to Database) •Advantages Does not require any native library Does not require any Middleware server Better Performance than other driver •Disadvantages Slow due to increase number of n/w call At client side, a separate driver is needed for each database 07/01/16 11
  • 12. Classes / Interfaces (java.sql package) 07/01/16 12
  • 13. Connection Interface Method Description void close() This method frees the connection object’s database and other JDBC resources void commit() This method makes all the changes made since the last commit or rollback. It throws SQLException boolean isClosed() This method returns “true” if the connection is close else returns “false” void rollback() This method undoes all changes made to the database Statement createStatement() This method creates a Statement object for sending SQL statements to the database. throws SQLException CallableStatement prepareCall(String s) This method creates a CallableStatement object for calling stored procedures. It throws SQLException PreparedStatement prepareStatement(String s) This method creates a PreparedStatement object for sending SQL statements with or without IN parameter. It throws SQLException. 07/01/16 13
  • 14. Statement Interface Method Description void close() this method releases the statement object’s database and JDBC resources boolean execute(String s) This method executes the SQL statement specified by s. ResultSet executeQuery(String s) This method executes the SQL statement specified by s and returns the ResultSet object int executeUpdate(String s) This method executes the SQL statement specified by s. These statements may be INSERT, UPDATE or DELETE int getMaxRows() This method returns the maximum number of rows that are generated by the executeQuery() method ResultSet getResultSet() This method retrieves the ResultSet generated by the execute() method 07/01/16 14

Editor's Notes