SlideShare a Scribd company logo
JDBC API Presenter:
Luzan Baral
Sijan Shrestha
Pratima Tiwari
What is an API?
• application program interface
• a set of routines, protocols, and tools for building software
applications
• provides all the building blocks
JDBC API
• JDBC is a Java Database Connectivity API that lets you access virtually
any tabular data source from a Java application.
• JDBC defines a low-level API designed to support basic SQL
functionality independently of any specific SQL implementation. This
means the focus is on executing raw SQL statements and retrieving
their results.
• The JDBC 2.0 API includes two packages: java.sql, known as the JDBC
2.0 core API and javax.sql, known as the JDBC Standard Extension.
Together, they contain the necessary classes to develop database
applications using Java.
JDBC API (cont..)
• The JDBC Extension Package (javax.sql) was introduced to contain the parts of the
JDBC API that are closely related to other pieces of the Java platform that are
themselves optional packages, such as the Java Naming and Directory Interface
(JNDI) and the Java Transaction Service (JTS).
• The JDBC API, found in the java.sql package, contains only a few concrete classes.
Much of the API is distributed as database-neutral interface classes that specify
behavior without providing any implementation. The actual implementations are
provided by third-party vendors.
How JDBC API helps?
1. Open a Connection
2. Send a statement
3. Retrieve results
4. Close a connection 1. Create a connection
Session
2. Execute statement
3. Send results
4. Close the session
Java Application
DBMS Engine
Java DB API
JDBC API works as a connectivity helper between Java Application between DBMS Engine
Using JDBC API
To execute a statement against a database, the following flow is observed
• Load the driver (only performed once)
• Obtain a Connection to the database (save for later use)
• Obtain a Statement object from the Connection
• Use the Statement object to execute SQL. Updates, inserts and deletes return Boolean.
Selects return a ResultSet
• Navigate ResultSet, using data as required
• Close ResultSet
• Close Statement
• The same connection object can be used to create further statements, so donot close the
Connection
• But close the connection when no longer need to access the database
Classes and Interfaces of java.sql
Class or Interfaces Description
java.sql.Connection Create a connection with specific database
java.sql.DriverManager The task of DriverManager is to manage the database driver
java.sql.Statement It executes SQL statements for particular connection and retrieve
the results
java.sql.PreparedStatement It allows the programmer to create prepared SQL statements
java.sql.CallableStatement It executes stored procedures
java.sql.ResultSet This interface provides methods to get result row by row generated
by SELECT statements
Methods in JDBC API - Connection
Method Description
void close() This methods frees an object of type Connection from database and other
JDBC resources
void commit() This method makes all the changes made since the last commit or rollback
permanent. It throws SQLException.
Statement createStatement() This method creates an object of type Statement for sending SQL
statements to the database. It throws SQLException.
boolean isClosed() Return true if the connection is closed else return false.
CallableStatement
prepareCall(String S)
This method creates an object of type CallableStatement for calling the
stored procedures from database. It throws SQLException.
PreparedStatedment
prepareStatement(String S)
This method creates an object of type PrepareStatement for sending
dynamic SQL statements to the database. It throws SQLException.
Void rollback() This method undoes all changes mage to the database.
Methods in JDBC API - Statement
Method Description
void close() This methods frees an object of type Statement from database and other
JDBC resources
boolean execute(String S) This method executes the SQL statement specified by s. The
getResultSet() method is used to retrieve the result.
ResultSet getResultSet() This method retrieves the ResultSet that is generated by the execute()
method.
ResultSet
executeQuery(String S)
This method is used to execute the SQL statement specified by s and
returns the object of type ResultSet.
Int getMaxRows() This method returns the maximum number of rows those are generated
by the executeQuery() method.
int executeUpdate(String s) This method executes the SQL statement specified by s. The SQL
statement may be a SQL insert, update and delete statement.
Thank You!
Follow me on Twitter @luzanb
Ad

Recommended

JDBC – Java Database Connectivity
JDBC – Java Database Connectivity
Information Technology
 
Java Server Pages(jsp)
Java Server Pages(jsp)
Manisha Keim
 
Introduction to method overloading & method overriding in java hdm
Introduction to method overloading & method overriding in java hdm
Harshal Misalkar
 
Java interfaces
Java interfaces
Raja Sekhar
 
Java 8 - Features Overview
Java 8 - Features Overview
Sergii Stets
 
JDBC
JDBC
People Strategists
 
Inheritance in JAVA PPT
Inheritance in JAVA PPT
Pooja Jaiswal
 
Interface in java
Interface in java
PhD Research Scholar
 
Mvc architecture
Mvc architecture
Surbhi Panhalkar
 
Jdbc architecture and driver types ppt
Jdbc architecture and driver types ppt
kamal kotecha
 
Generics and collections in Java
Generics and collections in Java
Gurpreet singh
 
Multithreading in java
Multithreading in java
Monika Mishra
 
Dynamic method dispatch
Dynamic method dispatch
yugandhar vadlamudi
 
Collections In Java
Collections In Java
Binoj T E
 
Abstract class in java
Abstract class in java
Lovely Professional University
 
Polymorphism in java
Polymorphism in java
Elizabeth alexander
 
Java abstract class & abstract methods
Java abstract class & abstract methods
Shubham Dwivedi
 
Ajax ppt
Ajax ppt
OECLIB Odisha Electronics Control Library
 
Arrays in Java
Arrays in Java
Naz Abdalla
 
JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - Objects
WebStackAcademy
 
Jdbc ppt
Jdbc ppt
sandeep54552
 
ADO.NET
ADO.NET
Farzad Wadia
 
OOP java
OOP java
xball977
 
Constructor in java
Constructor in java
Pavith Gunasekara
 
Java Server Pages
Java Server Pages
Kasun Madusanke
 
Java Servlets
Java Servlets
BG Java EE Course
 
Java Collection Framework
Java Collection Framework
Lakshmi R
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVA
VINOTH R
 
3 jdbc api
3 jdbc api
myrajendra
 
Jdbc api
Jdbc api
kamal kotecha
 

More Related Content

What's hot (20)

Mvc architecture
Mvc architecture
Surbhi Panhalkar
 
Jdbc architecture and driver types ppt
Jdbc architecture and driver types ppt
kamal kotecha
 
Generics and collections in Java
Generics and collections in Java
Gurpreet singh
 
Multithreading in java
Multithreading in java
Monika Mishra
 
Dynamic method dispatch
Dynamic method dispatch
yugandhar vadlamudi
 
Collections In Java
Collections In Java
Binoj T E
 
Abstract class in java
Abstract class in java
Lovely Professional University
 
Polymorphism in java
Polymorphism in java
Elizabeth alexander
 
Java abstract class & abstract methods
Java abstract class & abstract methods
Shubham Dwivedi
 
Ajax ppt
Ajax ppt
OECLIB Odisha Electronics Control Library
 
Arrays in Java
Arrays in Java
Naz Abdalla
 
JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - Objects
WebStackAcademy
 
Jdbc ppt
Jdbc ppt
sandeep54552
 
ADO.NET
ADO.NET
Farzad Wadia
 
OOP java
OOP java
xball977
 
Constructor in java
Constructor in java
Pavith Gunasekara
 
Java Server Pages
Java Server Pages
Kasun Madusanke
 
Java Servlets
Java Servlets
BG Java EE Course
 
Java Collection Framework
Java Collection Framework
Lakshmi R
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVA
VINOTH R
 

Viewers also liked (10)

3 jdbc api
3 jdbc api
myrajendra
 
Jdbc api
Jdbc api
kamal kotecha
 
Cultures of india
Cultures of india
Gowtham Raja
 
India
India
guestc9f3d3
 
Jdbc Ppt
Jdbc Ppt
Centre for Budget and Governance Accountability (CBGA)
 
Indian culture
Indian culture
sowju1830
 
INCREDIBLE INDIA
INCREDIBLE INDIA
Biswajit Ghosh
 
CULTURES OF INDIA
CULTURES OF INDIA
Jenisha Domadia
 
India Presentation
India Presentation
anujfun
 
Indian culture
Indian culture
Aayupta Mohanty
 
Ad

Similar to Java DataBase Connectivity API (JDBC API) (20)

Jdbc
Jdbc
DeepikaT13
 
Advance Java Practical file
Advance Java Practical file
varun arora
 
03-JDBC.pptx
03-JDBC.pptx
HachaluHaile
 
jdbc_presentation.ppt
jdbc_presentation.ppt
DrMeenakshiS
 
Java Database Connectivity
Java Database Connectivity
backdoor
 
Java Database Connectivity by shreyash simu dbce.pptx
Java Database Connectivity by shreyash simu dbce.pptx
ash909077
 
Jdbc connectivity
Jdbc connectivity
arikazukito
 
JDBC java for learning java for learn.ppt
JDBC java for learning java for learn.ppt
kingkolju
 
4-INTERDUCATION TO JDBC-2019.ppt
4-INTERDUCATION TO JDBC-2019.ppt
NaveenKumar648465
 
JDBC
JDBC
Manjunatha RK
 
JDBC PPT(4).pptx java Database Connectivity
JDBC PPT(4).pptx java Database Connectivity
dhanushoneplus00
 
Assignment#10
Assignment#10
Sunita Milind Dol
 
Jdbc ppt
Jdbc ppt
Vikas Jagtap
 
JDBC with MySQL.pdf
JDBC with MySQL.pdf
Arumugam90
 
JDBC with MySQL.pdf
JDBC with MySQL.pdf
Arumugam90
 
Java database connectivity with MySql
Java database connectivity with MySql
Dhyey Dattani
 
Java database connectivity with MySql
Java database connectivity with MySql
Dhyey Dattani
 
JDBC
JDBC
Sherif Mostafa
 
Jdbc (database in java)
Jdbc (database in java)
Maher Abdo
 
Java database connectivity
Java database connectivity
Vaishali Modi
 
Advance Java Practical file
Advance Java Practical file
varun arora
 
jdbc_presentation.ppt
jdbc_presentation.ppt
DrMeenakshiS
 
Java Database Connectivity
Java Database Connectivity
backdoor
 
Java Database Connectivity by shreyash simu dbce.pptx
Java Database Connectivity by shreyash simu dbce.pptx
ash909077
 
Jdbc connectivity
Jdbc connectivity
arikazukito
 
JDBC java for learning java for learn.ppt
JDBC java for learning java for learn.ppt
kingkolju
 
4-INTERDUCATION TO JDBC-2019.ppt
4-INTERDUCATION TO JDBC-2019.ppt
NaveenKumar648465
 
JDBC PPT(4).pptx java Database Connectivity
JDBC PPT(4).pptx java Database Connectivity
dhanushoneplus00
 
JDBC with MySQL.pdf
JDBC with MySQL.pdf
Arumugam90
 
JDBC with MySQL.pdf
JDBC with MySQL.pdf
Arumugam90
 
Java database connectivity with MySql
Java database connectivity with MySql
Dhyey Dattani
 
Java database connectivity with MySql
Java database connectivity with MySql
Dhyey Dattani
 
Jdbc (database in java)
Jdbc (database in java)
Maher Abdo
 
Java database connectivity
Java database connectivity
Vaishali Modi
 
Ad

Recently uploaded (20)

Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
dayananda54
 
Stay Safe Women Security Android App Project Report.pdf
Stay Safe Women Security Android App Project Report.pdf
Kamal Acharya
 
special_edition_using_visual_foxpro_6.pdf
special_edition_using_visual_foxpro_6.pdf
Shabista Imam
 
How Binning Affects LED Performance & Consistency.pdf
How Binning Affects LED Performance & Consistency.pdf
Mina Anis
 
最新版美国圣莫尼卡学院毕业证(SMC毕业证书)原版定制
最新版美国圣莫尼卡学院毕业证(SMC毕业证书)原版定制
Taqyea
 
Industrial internet of things IOT Week-3.pptx
Industrial internet of things IOT Week-3.pptx
KNaveenKumarECE
 
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Alexandra N. Martinez
 
VARICELLA VACCINATION: A POTENTIAL STRATEGY FOR PREVENTING MULTIPLE SCLEROSIS
VARICELLA VACCINATION: A POTENTIAL STRATEGY FOR PREVENTING MULTIPLE SCLEROSIS
ijab2
 
IPL_Logic_Flow.pdf Mainframe IPLMainframe IPL
IPL_Logic_Flow.pdf Mainframe IPLMainframe IPL
KhadijaKhadijaAouadi
 
System design handwritten notes guidance
System design handwritten notes guidance
Shabista Imam
 
Structured Programming with C++ :: Kjell Backman
Structured Programming with C++ :: Kjell Backman
Shabista Imam
 
Tally.ERP 9 at a Glance.book - Tally Solutions .pdf
Tally.ERP 9 at a Glance.book - Tally Solutions .pdf
Shabista Imam
 
Pavement and its types, Application of rigid and Flexible Pavements
Pavement and its types, Application of rigid and Flexible Pavements
Sakthivel M
 
Industry 4.o the fourth revolutionWeek-2.pptx
Industry 4.o the fourth revolutionWeek-2.pptx
KNaveenKumarECE
 
Machine Learning - Classification Algorithms
Machine Learning - Classification Algorithms
resming1
 
Fundamentals of Digital Design_Class_21st May - Copy.pptx
Fundamentals of Digital Design_Class_21st May - Copy.pptx
drdebarshi1993
 
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
resming1
 
Complete guidance book of Asp.Net Web API
Complete guidance book of Asp.Net Web API
Shabista Imam
 
Modern multi-proposer consensus implementations
Modern multi-proposer consensus implementations
François Garillot
 
Proposal for folders structure division in projects.pdf
Proposal for folders structure division in projects.pdf
Mohamed Ahmed
 
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
dayananda54
 
Stay Safe Women Security Android App Project Report.pdf
Stay Safe Women Security Android App Project Report.pdf
Kamal Acharya
 
special_edition_using_visual_foxpro_6.pdf
special_edition_using_visual_foxpro_6.pdf
Shabista Imam
 
How Binning Affects LED Performance & Consistency.pdf
How Binning Affects LED Performance & Consistency.pdf
Mina Anis
 
最新版美国圣莫尼卡学院毕业证(SMC毕业证书)原版定制
最新版美国圣莫尼卡学院毕业证(SMC毕业证书)原版定制
Taqyea
 
Industrial internet of things IOT Week-3.pptx
Industrial internet of things IOT Week-3.pptx
KNaveenKumarECE
 
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Montreal Dreamin' 25 - Introduction to the MuleSoft AI Chain (MAC) Project
Alexandra N. Martinez
 
VARICELLA VACCINATION: A POTENTIAL STRATEGY FOR PREVENTING MULTIPLE SCLEROSIS
VARICELLA VACCINATION: A POTENTIAL STRATEGY FOR PREVENTING MULTIPLE SCLEROSIS
ijab2
 
IPL_Logic_Flow.pdf Mainframe IPLMainframe IPL
IPL_Logic_Flow.pdf Mainframe IPLMainframe IPL
KhadijaKhadijaAouadi
 
System design handwritten notes guidance
System design handwritten notes guidance
Shabista Imam
 
Structured Programming with C++ :: Kjell Backman
Structured Programming with C++ :: Kjell Backman
Shabista Imam
 
Tally.ERP 9 at a Glance.book - Tally Solutions .pdf
Tally.ERP 9 at a Glance.book - Tally Solutions .pdf
Shabista Imam
 
Pavement and its types, Application of rigid and Flexible Pavements
Pavement and its types, Application of rigid and Flexible Pavements
Sakthivel M
 
Industry 4.o the fourth revolutionWeek-2.pptx
Industry 4.o the fourth revolutionWeek-2.pptx
KNaveenKumarECE
 
Machine Learning - Classification Algorithms
Machine Learning - Classification Algorithms
resming1
 
Fundamentals of Digital Design_Class_21st May - Copy.pptx
Fundamentals of Digital Design_Class_21st May - Copy.pptx
drdebarshi1993
 
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
Deep Learning for Natural Language Processing_FDP on 16 June 2025 MITS.pptx
resming1
 
Complete guidance book of Asp.Net Web API
Complete guidance book of Asp.Net Web API
Shabista Imam
 
Modern multi-proposer consensus implementations
Modern multi-proposer consensus implementations
François Garillot
 
Proposal for folders structure division in projects.pdf
Proposal for folders structure division in projects.pdf
Mohamed Ahmed
 

Java DataBase Connectivity API (JDBC API)

  • 1. JDBC API Presenter: Luzan Baral Sijan Shrestha Pratima Tiwari
  • 2. What is an API? • application program interface • a set of routines, protocols, and tools for building software applications • provides all the building blocks
  • 3. JDBC API • JDBC is a Java Database Connectivity API that lets you access virtually any tabular data source from a Java application. • JDBC defines a low-level API designed to support basic SQL functionality independently of any specific SQL implementation. This means the focus is on executing raw SQL statements and retrieving their results. • The JDBC 2.0 API includes two packages: java.sql, known as the JDBC 2.0 core API and javax.sql, known as the JDBC Standard Extension. Together, they contain the necessary classes to develop database applications using Java.
  • 4. JDBC API (cont..) • The JDBC Extension Package (javax.sql) was introduced to contain the parts of the JDBC API that are closely related to other pieces of the Java platform that are themselves optional packages, such as the Java Naming and Directory Interface (JNDI) and the Java Transaction Service (JTS). • The JDBC API, found in the java.sql package, contains only a few concrete classes. Much of the API is distributed as database-neutral interface classes that specify behavior without providing any implementation. The actual implementations are provided by third-party vendors.
  • 5. How JDBC API helps? 1. Open a Connection 2. Send a statement 3. Retrieve results 4. Close a connection 1. Create a connection Session 2. Execute statement 3. Send results 4. Close the session Java Application DBMS Engine Java DB API JDBC API works as a connectivity helper between Java Application between DBMS Engine
  • 6. Using JDBC API To execute a statement against a database, the following flow is observed • Load the driver (only performed once) • Obtain a Connection to the database (save for later use) • Obtain a Statement object from the Connection • Use the Statement object to execute SQL. Updates, inserts and deletes return Boolean. Selects return a ResultSet • Navigate ResultSet, using data as required • Close ResultSet • Close Statement • The same connection object can be used to create further statements, so donot close the Connection • But close the connection when no longer need to access the database
  • 7. Classes and Interfaces of java.sql Class or Interfaces Description java.sql.Connection Create a connection with specific database java.sql.DriverManager The task of DriverManager is to manage the database driver java.sql.Statement It executes SQL statements for particular connection and retrieve the results java.sql.PreparedStatement It allows the programmer to create prepared SQL statements java.sql.CallableStatement It executes stored procedures java.sql.ResultSet This interface provides methods to get result row by row generated by SELECT statements
  • 8. Methods in JDBC API - Connection Method Description void close() This methods frees an object of type Connection from database and other JDBC resources void commit() This method makes all the changes made since the last commit or rollback permanent. It throws SQLException. Statement createStatement() This method creates an object of type Statement for sending SQL statements to the database. It throws SQLException. boolean isClosed() Return true if the connection is closed else return false. CallableStatement prepareCall(String S) This method creates an object of type CallableStatement for calling the stored procedures from database. It throws SQLException. PreparedStatedment prepareStatement(String S) This method creates an object of type PrepareStatement for sending dynamic SQL statements to the database. It throws SQLException. Void rollback() This method undoes all changes mage to the database.
  • 9. Methods in JDBC API - Statement Method Description void close() This methods frees an object of type Statement from database and other JDBC resources boolean execute(String S) This method executes the SQL statement specified by s. The getResultSet() method is used to retrieve the result. ResultSet getResultSet() This method retrieves the ResultSet that is generated by the execute() method. ResultSet executeQuery(String S) This method is used to execute the SQL statement specified by s and returns the object of type ResultSet. Int getMaxRows() This method returns the maximum number of rows those are generated by the executeQuery() method. int executeUpdate(String s) This method executes the SQL statement specified by s. The SQL statement may be a SQL insert, update and delete statement.
  • 10. Thank You! Follow me on Twitter @luzanb