SlideShare a Scribd company logo
1 of 14
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

What's hot

Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
Raghu nath
 
Byte stream classes.49
Byte stream classes.49Byte stream classes.49
Byte stream classes.49
myrajendra
 

What's hot (20)

Jdbc
JdbcJdbc
Jdbc
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Java - Generic programming
Java - Generic programmingJava - Generic programming
Java - Generic programming
 
JDBC – Java Database Connectivity
JDBC – Java Database ConnectivityJDBC – Java Database Connectivity
JDBC – Java Database Connectivity
 
JDBC Java Database Connectivity
JDBC Java Database ConnectivityJDBC Java Database Connectivity
JDBC Java Database Connectivity
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
 
Java Lambda Expressions.pptx
Java Lambda Expressions.pptxJava Lambda Expressions.pptx
Java Lambda Expressions.pptx
 
jdbc document
jdbc documentjdbc document
jdbc document
 
Er model ppt
Er model pptEr model ppt
Er model ppt
 
Java database connectivity with MYSQL
Java database connectivity with MYSQLJava database connectivity with MYSQL
Java database connectivity with MYSQL
 
Byte stream classes.49
Byte stream classes.49Byte stream classes.49
Byte stream classes.49
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
 
MySQL ppt
MySQL ppt MySQL ppt
MySQL ppt
 
Sql Basics And Advanced
Sql Basics And AdvancedSql Basics And Advanced
Sql Basics And Advanced
 
Generics
GenericsGenerics
Generics
 
Applets in java
Applets in javaApplets in java
Applets in java
 
Java Collections
Java  Collections Java  Collections
Java Collections
 
Servlet and servlet life cycle
Servlet and servlet life cycleServlet and servlet life cycle
Servlet and servlet life cycle
 
Collection Framework in java
Collection Framework in javaCollection Framework in java
Collection Framework in java
 
Wrapper class
Wrapper classWrapper class
Wrapper class
 

Viewers also liked

Collections In Java
Collections In JavaCollections In Java
Collections In Java
Binoj T E
 

Viewers also liked (20)

Java Beans
Java BeansJava Beans
Java Beans
 
Jdbc Ppt
Jdbc PptJdbc Ppt
Jdbc Ppt
 
Presentation15 parse xml
Presentation15 parse xmlPresentation15 parse xml
Presentation15 parse xml
 
Presentation14 audio play
Presentation14 audio playPresentation14 audio play
Presentation14 audio play
 
Presentation11 sq lite
Presentation11 sq litePresentation11 sq lite
Presentation11 sq lite
 
Presentation8 silder switch_progress
Presentation8 silder switch_progressPresentation8 silder switch_progress
Presentation8 silder switch_progress
 
Presentation4 date picker
Presentation4 date pickerPresentation4 date picker
Presentation4 date picker
 
Hadoop installation
Hadoop installationHadoop installation
Hadoop installation
 
java code and document security
java code and document securityjava code and document security
java code and document security
 
Java Generics for Dummies
Java Generics for DummiesJava Generics for Dummies
Java Generics for Dummies
 
Java AWT
Java AWTJava AWT
Java AWT
 
java drag and drop and data transfer
java drag and drop and data transferjava drag and drop and data transfer
java drag and drop and data transfer
 
Java Generics
Java GenericsJava Generics
Java Generics
 
Java Generics
Java GenericsJava Generics
Java Generics
 
Event handling
Event handlingEvent handling
Event handling
 
Bean Intro
Bean IntroBean Intro
Bean Intro
 
Java bean
Java beanJava bean
Java bean
 
Collections In Java
Collections In JavaCollections In Java
Collections In Java
 
Java beans
Java beansJava beans
Java beans
 
Javabeans
JavabeansJavabeans
Javabeans
 

Similar to java Jdbc

JDBC java for learning java for learn.ppt
JDBC java for learning java for learn.pptJDBC java for learning java for learn.ppt
JDBC java for learning java for learn.ppt
kingkolju
 

Similar to java Jdbc (20)

Java unit 14
Java unit 14Java unit 14
Java unit 14
 
Unit 5.pdf
Unit 5.pdfUnit 5.pdf
Unit 5.pdf
 
java.pptx
java.pptxjava.pptx
java.pptx
 
Java database connectivity
Java database connectivityJava database connectivity
Java database connectivity
 
Java database connectivity
Java database connectivityJava database connectivity
Java database connectivity
 
Core jdbc basics
Core jdbc basicsCore jdbc basics
Core jdbc basics
 
Jdbc introduction
Jdbc introductionJdbc introduction
Jdbc introduction
 
JDBC java database connectivity with dbms
JDBC java database connectivity with dbmsJDBC java database connectivity with dbms
JDBC java database connectivity with dbms
 
jdbc
jdbcjdbc
jdbc
 
Jdbc driver types
Jdbc driver typesJdbc driver types
Jdbc driver types
 
Jdbc architecture and driver types ppt
Jdbc architecture and driver types pptJdbc architecture and driver types ppt
Jdbc architecture and driver types ppt
 
jdbc
jdbcjdbc
jdbc
 
Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)
 
4-INTERDUCATION TO JDBC-2019.ppt
4-INTERDUCATION TO JDBC-2019.ppt4-INTERDUCATION TO JDBC-2019.ppt
4-INTERDUCATION TO JDBC-2019.ppt
 
JDBC java for learning java for learn.ppt
JDBC java for learning java for learn.pptJDBC java for learning java for learn.ppt
JDBC java for learning java for learn.ppt
 
Jdbc complete
Jdbc completeJdbc complete
Jdbc complete
 
Jdbc
JdbcJdbc
Jdbc
 
Jdbc
JdbcJdbc
Jdbc
 
java 4 Part 1 computer science.pptx
java 4 Part 1 computer science.pptxjava 4 Part 1 computer science.pptx
java 4 Part 1 computer science.pptx
 
3 jdbc
3 jdbc3 jdbc
3 jdbc
 

More from Ankit Desai

More from Ankit Desai (11)

Java RMI
Java RMIJava RMI
Java RMI
 
java swing programming
java swing programming java swing programming
java swing programming
 
Java Networking
Java NetworkingJava Networking
Java Networking
 
JDBC
JDBCJDBC
JDBC
 
Presentation10 view navigation
Presentation10 view navigationPresentation10 view navigation
Presentation10 view navigation
 
Presentation7 segment control
Presentation7 segment controlPresentation7 segment control
Presentation7 segment control
 
Presentation6 ui image_view
Presentation6 ui image_viewPresentation6 ui image_view
Presentation6 ui image_view
 
Presentation5 picker view
Presentation5 picker viewPresentation5 picker view
Presentation5 picker view
 
Presentation3 actionsheet alertview
Presentation3 actionsheet alertviewPresentation3 actionsheet alertview
Presentation3 actionsheet alertview
 
Presentation1 password
Presentation1 passwordPresentation1 password
Presentation1 password
 
Presentation2 gesture control
Presentation2 gesture controlPresentation2 gesture control
Presentation2 gesture control
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

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

  1. 1