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

More Related Content

What's hot (20)

PDF
JavaFX Overview
José Maria Silveira Neto
 
PPSX
Fundamentals of JDBC
Jainul Musani
 
PPTX
Java Server Pages(jsp)
Manisha Keim
 
PPTX
Jdbc_ravi_2016
Ravinder Singh Karki
 
PPTX
Spring data jpa
Jeevesh Pandey
 
PPTX
Jdbc ppt
sandeep54552
 
PPTX
Introduction to spring boot
Santosh Kumar Kar
 
PPT
JQuery introduction
NexThoughts Technologies
 
PPTX
Chapter2 j2ee
Jafar Nesargi
 
PPTX
Spring boot Introduction
Jeevesh Pandey
 
PPS
Jdbc architecture and driver types ppt
kamal kotecha
 
PPTX
What Is Express JS?
Simplilearn
 
PPTX
java Jdbc
Ankit Desai
 
PPT
Tomcat
Venkat Pinagadi
 
PPTX
Enterprise java unit-1_chapter-3
sandeep54552
 
PDF
Spring boot jpa
Hamid Ghorbani
 
PDF
Learn Entity Framework in a day with Code First, Model First and Database First
Jibran Rasheed Khan
 
PPTX
Spring Boot
Jiayun Zhou
 
JavaFX Overview
José Maria Silveira Neto
 
Fundamentals of JDBC
Jainul Musani
 
Java Server Pages(jsp)
Manisha Keim
 
Jdbc_ravi_2016
Ravinder Singh Karki
 
Spring data jpa
Jeevesh Pandey
 
Jdbc ppt
sandeep54552
 
Introduction to spring boot
Santosh Kumar Kar
 
JQuery introduction
NexThoughts Technologies
 
Chapter2 j2ee
Jafar Nesargi
 
Spring boot Introduction
Jeevesh Pandey
 
Jdbc architecture and driver types ppt
kamal kotecha
 
What Is Express JS?
Simplilearn
 
java Jdbc
Ankit Desai
 
Enterprise java unit-1_chapter-3
sandeep54552
 
Spring boot jpa
Hamid Ghorbani
 
Learn Entity Framework in a day with Code First, Model First and Database First
Jibran Rasheed Khan
 
Spring Boot
Jiayun Zhou
 

Viewers also liked (9)

PPTX
3 jdbc api
myrajendra
 
PPS
Jdbc api
kamal kotecha
 
PPTX
Cultures of india
Gowtham Raja
 
PPT
India
guestc9f3d3
 
PPSX
Indian culture
sowju1830
 
PPT
INCREDIBLE INDIA
Biswajit Ghosh
 
PPSX
CULTURES OF INDIA
Jenisha Domadia
 
PPTX
India Presentation
anujfun
 
PPTX
Indian culture
Aayupta Mohanty
 
3 jdbc api
myrajendra
 
Jdbc api
kamal kotecha
 
Cultures of india
Gowtham Raja
 
Indian culture
sowju1830
 
INCREDIBLE INDIA
Biswajit Ghosh
 
CULTURES OF INDIA
Jenisha Domadia
 
India Presentation
anujfun
 
Indian culture
Aayupta Mohanty
 
Ad

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

PDF
Presentation for java data base connectivity
kanjariya006
 
PPTX
Core jdbc basics
Sourabrata Mukherjee
 
PDF
Jdbc
mishaRani1
 
PPT
jdbc_presentation.ppt
DrMeenakshiS
 
PPT
Jdbc sasidhar
Sasidhar Kothuru
 
PPTX
Jdbc
Yamuna Devi
 
PPTX
Jdjdbcbc Jdjdbcbc JdjdbcJdjdbcbc Jdjdbcbc Jdjdbcbcbc JdJdbcbc
rohanbawadkar
 
PPTX
Jdbc
DeepikaT13
 
PPTX
Java Database Connectivity by shreyash simu dbce.pptx
ash909077
 
PPTX
Java- JDBC- Mazenet Solution
Mazenetsolution
 
PPT
JDBC Connectivity Model
kunj desai
 
PPT
JDBC.ppt
Jayaprasanna4
 
PPT
Java jdbc
Arati Gadgil
 
PPTX
Database connect
Yoga Raja
 
PPTX
Jdbc presentation
nrjoshiee
 
PPTX
JDBC PPT(4).pptx java Database Connectivity
dhanushoneplus00
 
PDF
Jdbc 1
Tuan Ngo
 
PPT
Jdbc connectivity
arikazukito
 
PPT
Java Database Connectivity
backdoor
 
Presentation for java data base connectivity
kanjariya006
 
Core jdbc basics
Sourabrata Mukherjee
 
jdbc_presentation.ppt
DrMeenakshiS
 
Jdbc sasidhar
Sasidhar Kothuru
 
Jdjdbcbc Jdjdbcbc JdjdbcJdjdbcbc Jdjdbcbc Jdjdbcbcbc JdJdbcbc
rohanbawadkar
 
Java Database Connectivity by shreyash simu dbce.pptx
ash909077
 
Java- JDBC- Mazenet Solution
Mazenetsolution
 
JDBC Connectivity Model
kunj desai
 
JDBC.ppt
Jayaprasanna4
 
Java jdbc
Arati Gadgil
 
Database connect
Yoga Raja
 
Jdbc presentation
nrjoshiee
 
JDBC PPT(4).pptx java Database Connectivity
dhanushoneplus00
 
Jdbc 1
Tuan Ngo
 
Jdbc connectivity
arikazukito
 
Java Database Connectivity
backdoor
 
Ad

Recently uploaded (20)

PDF
Electrical Machines and Their Protection.pdf
Nabajyoti Banik
 
DOCX
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
PPTX
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
PDF
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
PPTX
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
PPTX
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
PPTX
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
PPTX
MATLAB : Introduction , Features , Display Windows, Syntax, Operators, Graph...
Amity University, Patna
 
PDF
AN EMPIRICAL STUDY ON THE USAGE OF SOCIAL MEDIA IN GERMAN B2C-ONLINE STORES
ijait
 
PPT
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 
PDF
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
DOC
MRRS Strength and Durability of Concrete
CivilMythili
 
PPTX
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
PPTX
Knowledge Representation : Semantic Networks
Amity University, Patna
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
PPTX
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
PPTX
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
PDF
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
PDF
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
Electrical Machines and Their Protection.pdf
Nabajyoti Banik
 
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
MATLAB : Introduction , Features , Display Windows, Syntax, Operators, Graph...
Amity University, Patna
 
AN EMPIRICAL STUDY ON THE USAGE OF SOCIAL MEDIA IN GERMAN B2C-ONLINE STORES
ijait
 
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
MRRS Strength and Durability of Concrete
CivilMythili
 
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
Knowledge Representation : Semantic Networks
Amity University, Patna
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
美国电子版毕业证南卡罗莱纳大学上州分校水印成绩单USC学费发票定做学位证书编号怎么查
Taqyea
 
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 

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