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)

PPT
Java Servlets
BG Java EE Course
 
PPTX
Polymorphism presentation in java
Ahsan Raja
 
PPT
Java servlets
lopjuan
 
PPT
Collection Framework in java
CPD INDIA
 
PPTX
Java Server Pages(jsp)
Manisha Keim
 
PPTX
Servlets
ZainabNoorGul
 
PPTX
Java swing
Apurbo Datta
 
PDF
Java I/o streams
Hamid Ghorbani
 
PPTX
Servlets
Akshay Ballarpure
 
PPTX
Introduction to Node.js
Vikash Singh
 
PPSX
Sessions and cookies
www.netgains.org
 
PDF
Remote Method Invocation (RMI)
Peter R. Egli
 
PPT
Introduction to method overloading & method overriding in java hdm
Harshal Misalkar
 
PPT
Java interfaces
Raja Sekhar
 
PPSX
Frequent itemset mining methods
Prof.Nilesh Magar
 
PPT
Fundamentals of JAVA
KUNAL GADHIA
 
PPTX
Computer Science:Java jdbc
St Mary's College,Thrissur,Kerala
 
PPTX
Exception handling in asp.net
Neelesh Shukla
 
PPT
Java collections concept
kumar gaurav
 
PPTX
JAVA AWT
shanmuga rajan
 
Java Servlets
BG Java EE Course
 
Polymorphism presentation in java
Ahsan Raja
 
Java servlets
lopjuan
 
Collection Framework in java
CPD INDIA
 
Java Server Pages(jsp)
Manisha Keim
 
Servlets
ZainabNoorGul
 
Java swing
Apurbo Datta
 
Java I/o streams
Hamid Ghorbani
 
Introduction to Node.js
Vikash Singh
 
Sessions and cookies
www.netgains.org
 
Remote Method Invocation (RMI)
Peter R. Egli
 
Introduction to method overloading & method overriding in java hdm
Harshal Misalkar
 
Java interfaces
Raja Sekhar
 
Frequent itemset mining methods
Prof.Nilesh Magar
 
Fundamentals of JAVA
KUNAL GADHIA
 
Computer Science:Java jdbc
St Mary's College,Thrissur,Kerala
 
Exception handling in asp.net
Neelesh Shukla
 
Java collections concept
kumar gaurav
 
JAVA AWT
shanmuga rajan
 

Viewers also liked (10)

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_ravi_2016
Ravinder Singh Karki
 
PPTX
Jdbc presentation
nrjoshiee
 
PPTX
JDBC PPT(4).pptx java Database Connectivity
dhanushoneplus00
 
PDF
Jdbc 1
Tuan Ngo
 
PPT
Jdbc connectivity
arikazukito
 
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_ravi_2016
Ravinder Singh Karki
 
Jdbc presentation
nrjoshiee
 
JDBC PPT(4).pptx java Database Connectivity
dhanushoneplus00
 
Jdbc 1
Tuan Ngo
 
Jdbc connectivity
arikazukito
 
Ad

Recently uploaded (20)

PPTX
GitOps_Repo_Structure for begeinner(Scaffolindg)
DanialHabibi2
 
PDF
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
PPTX
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
PDF
Unified_Cloud_Comm_Presentation anil singh ppt
anilsingh298751
 
PPTX
Arduino Based Gas Leakage Detector Project
CircuitDigest
 
PDF
Zilliz Cloud Demo for performance and scale
Zilliz
 
PPTX
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
PPTX
Introduction to Design of Machine Elements
PradeepKumarS27
 
PPTX
Green Building & Energy Conservation ppt
Sagar Sarangi
 
PPTX
MobileComputingMANET2023 MobileComputingMANET2023.pptx
masterfake98765
 
PDF
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
PPT
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
PPTX
Depth First Search Algorithm in 🧠 DFS in Artificial Intelligence (AI)
rafeeqshaik212002
 
PDF
GTU Civil Engineering All Semester Syllabus.pdf
Vimal Bhojani
 
DOC
MRRS Strength and Durability of Concrete
CivilMythili
 
PPTX
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
PPTX
Evaluation and thermal analysis of shell and tube heat exchanger as per requi...
shahveer210504
 
PPTX
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
PPTX
Types of Bearing_Specifications_PPT.pptx
PranjulAgrahariAkash
 
GitOps_Repo_Structure for begeinner(Scaffolindg)
DanialHabibi2
 
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
Unified_Cloud_Comm_Presentation anil singh ppt
anilsingh298751
 
Arduino Based Gas Leakage Detector Project
CircuitDigest
 
Zilliz Cloud Demo for performance and scale
Zilliz
 
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
Introduction to Design of Machine Elements
PradeepKumarS27
 
Green Building & Energy Conservation ppt
Sagar Sarangi
 
MobileComputingMANET2023 MobileComputingMANET2023.pptx
masterfake98765
 
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
Depth First Search Algorithm in 🧠 DFS in Artificial Intelligence (AI)
rafeeqshaik212002
 
GTU Civil Engineering All Semester Syllabus.pdf
Vimal Bhojani
 
MRRS Strength and Durability of Concrete
CivilMythili
 
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
Evaluation and thermal analysis of shell and tube heat exchanger as per requi...
shahveer210504
 
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
Types of Bearing_Specifications_PPT.pptx
PranjulAgrahariAkash
 

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