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

PPT
JDBC – Java Database Connectivity
PDF
Javascript essentials
PPTX
JPA For Beginner's
PDF
CNIT 126: 10: Kernel Debugging with WinDbg
PDF
Java Course 8: I/O, Files and Streams
PPT
Mysql
PDF
4.3 MySQL + PHP
PPT
Thread model in java
JDBC – Java Database Connectivity
Javascript essentials
JPA For Beginner's
CNIT 126: 10: Kernel Debugging with WinDbg
Java Course 8: I/O, Files and Streams
Mysql
4.3 MySQL + PHP
Thread model in java

What's hot (20)

PPTX
JAVA AWT
PPT
Multivalued dependency
PDF
Nested Queries Lecture
PPTX
Interfaces in java
PPTX
Applets in java
PDF
Threads concept in java
PPT
Core java concepts
PPT
Object Oriented Concepts and Principles
PPT
JDBC Architecture and Drivers
PPTX
Database Programming
PPT
Spring AOP
PPT
Polymorphism in java, method overloading and method overriding
PPT
Java database connectivity
PPTX
Interface in java
PDF
Hibernate Presentation
PDF
PL-SQL, Cursors & Triggers
PPSX
JDBC: java DataBase connectivity
PDF
SQL Injection Tutorial
PPTX
Access specifiers(modifiers) in java
JAVA AWT
Multivalued dependency
Nested Queries Lecture
Interfaces in java
Applets in java
Threads concept in java
Core java concepts
Object Oriented Concepts and Principles
JDBC Architecture and Drivers
Database Programming
Spring AOP
Polymorphism in java, method overloading and method overriding
Java database connectivity
Interface in java
Hibernate Presentation
PL-SQL, Cursors & Triggers
JDBC: java DataBase connectivity
SQL Injection Tutorial
Access specifiers(modifiers) in java
Ad

Viewers also liked (9)

PPTX
3 jdbc api
PPS
Jdbc api
PPTX
Cultures of india
PPT
PPSX
Indian culture
PPT
INCREDIBLE INDIA
PPSX
CULTURES OF INDIA
PPTX
India Presentation
PPTX
Indian culture
3 jdbc api
Jdbc api
Cultures of india
Indian culture
INCREDIBLE INDIA
CULTURES OF INDIA
India Presentation
Indian culture
Ad

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

PPTX
PDF
Advance Java Practical file
PPTX
03-JDBC.pptx
PPT
jdbc_presentation.ppt
PPT
Java Database Connectivity
PPTX
Java Database Connectivity by shreyash simu dbce.pptx
PPT
Jdbc connectivity
PPT
JDBC java for learning java for learn.ppt
PPT
4-INTERDUCATION TO JDBC-2019.ppt
DOC
PPTX
JDBC PPT(4).pptx java Database Connectivity
PDF
Assignment#10
PPT
Jdbc ppt
PDF
JDBC with MySQL.pdf
PDF
JDBC with MySQL.pdf
PPTX
Java database connectivity with MySql
PPTX
Java database connectivity with MySql
PPTX
PPT
Jdbc (database in java)
PPT
Java database connectivity
Advance Java Practical file
03-JDBC.pptx
jdbc_presentation.ppt
Java Database Connectivity
Java Database Connectivity by shreyash simu dbce.pptx
Jdbc connectivity
JDBC java for learning java for learn.ppt
4-INTERDUCATION TO JDBC-2019.ppt
JDBC PPT(4).pptx java Database Connectivity
Assignment#10
Jdbc ppt
JDBC with MySQL.pdf
JDBC with MySQL.pdf
Java database connectivity with MySql
Java database connectivity with MySql
Jdbc (database in java)
Java database connectivity

Recently uploaded (20)

PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
OOP with Java - Java Introduction (Basics)
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
Foundation to blockchain - A guide to Blockchain Tech
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
Geodesy 1.pptx...............................................
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PDF
PPT on Performance Review to get promotions
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
Well-logging-methods_new................
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PPTX
Welding lecture in detail for understanding
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
bas. eng. economics group 4 presentation 1.pptx
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
OOP with Java - Java Introduction (Basics)
Operating System & Kernel Study Guide-1 - converted.pdf
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Foundation to blockchain - A guide to Blockchain Tech
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Geodesy 1.pptx...............................................
Lesson 3_Tessellation.pptx finite Mathematics
PPT on Performance Review to get promotions
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
UNIT-1 - COAL BASED THERMAL POWER PLANTS
CYBER-CRIMES AND SECURITY A guide to understanding
Well-logging-methods_new................
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Model Code of Practice - Construction Work - 21102022 .pdf
Strings in CPP - Strings in C++ are sequences of characters used to store and...
Welding lecture in detail for understanding
Embodied AI: Ushering in the Next Era of Intelligent Systems

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