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

Java database connectivity with MySql
Java database connectivity with MySqlJava database connectivity with MySql
Java database connectivity with MySql
Dhyey Dattani
 
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
Edureka!
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot Introduction
Jeevesh Pandey
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
Purbarun Chakrabarti
 
JDBC
JDBCJDBC
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...
Mr. Akaash
 
Exception Handling in JAVA
Exception Handling in JAVAException Handling in JAVA
Exception Handling in JAVA
SURIT DATTA
 
Spring boot
Spring bootSpring boot
Spring boot
Pradeep Shanmugam
 
Collections framework in java
Collections framework in javaCollections framework in java
Collections framework in java
yugandhar vadlamudi
 
Java And Multithreading
Java And MultithreadingJava And Multithreading
Java And Multithreading
Shraddha
 
Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
Santosh Kumar Kar
 
Servlet life cycle
Servlet life cycleServlet life cycle
Servlet life cycle
Venkateswara Rao N
 
Spring Boot
Spring BootSpring Boot
Spring Boot
HongSeong Jeon
 
JAVA ENVIRONMENT
JAVA  ENVIRONMENTJAVA  ENVIRONMENT
JAVA ENVIRONMENT
josemachoco
 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
Manisha Keim
 
Applets
AppletsApplets
JDBC Architecture and Drivers
JDBC Architecture and DriversJDBC Architecture and Drivers
JDBC Architecture and Drivers
SimoniShah6
 
Java Collections
Java  Collections Java  Collections
Jdbc Ppt
Jdbc PptJdbc Ppt
Threads concept in java
Threads concept in javaThreads concept in java
Threads concept in java
Muthukumaran Subramanian
 

What's hot (20)

Java database connectivity with MySql
Java database connectivity with MySqlJava database connectivity with MySql
Java database connectivity with MySql
 
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
Java Collections | Collections Framework in Java | Java Tutorial For Beginner...
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot Introduction
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
JDBC
JDBCJDBC
JDBC
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...
 
Exception Handling in JAVA
Exception Handling in JAVAException Handling in JAVA
Exception Handling in JAVA
 
Spring boot
Spring bootSpring boot
Spring boot
 
Collections framework in java
Collections framework in javaCollections framework in java
Collections framework in java
 
Java And Multithreading
Java And MultithreadingJava And Multithreading
Java And Multithreading
 
Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
 
Servlet life cycle
Servlet life cycleServlet life cycle
Servlet life cycle
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
JAVA ENVIRONMENT
JAVA  ENVIRONMENTJAVA  ENVIRONMENT
JAVA ENVIRONMENT
 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
 
Applets
AppletsApplets
Applets
 
JDBC Architecture and Drivers
JDBC Architecture and DriversJDBC Architecture and Drivers
JDBC Architecture and Drivers
 
Java Collections
Java  Collections Java  Collections
Java Collections
 
Jdbc Ppt
Jdbc PptJdbc Ppt
Jdbc Ppt
 
Threads concept in java
Threads concept in javaThreads concept in java
Threads concept in java
 

Viewers also liked

3 jdbc api
3 jdbc api3 jdbc api
3 jdbc api
myrajendra
 
Jdbc api
Jdbc apiJdbc api
Jdbc api
kamal kotecha
 
Cultures of india
Cultures of indiaCultures of india
Cultures of india
Gowtham Raja
 
India
IndiaIndia
Indian culture
Indian cultureIndian culture
Indian culture
sowju1830
 
INCREDIBLE INDIA
INCREDIBLE INDIAINCREDIBLE INDIA
INCREDIBLE INDIA
Biswajit Ghosh
 
CULTURES OF INDIA
CULTURES OF INDIACULTURES OF INDIA
CULTURES OF INDIA
Jenisha Domadia
 
India Presentation
India PresentationIndia Presentation
India Presentation
anujfun
 
Indian culture
Indian cultureIndian culture
Indian culture
Aayupta Mohanty
 

Viewers also liked (9)

3 jdbc api
3 jdbc api3 jdbc api
3 jdbc api
 
Jdbc api
Jdbc apiJdbc api
Jdbc api
 
Cultures of india
Cultures of indiaCultures of india
Cultures of india
 
India
IndiaIndia
India
 
Indian culture
Indian cultureIndian culture
Indian culture
 
INCREDIBLE INDIA
INCREDIBLE INDIAINCREDIBLE INDIA
INCREDIBLE INDIA
 
CULTURES OF INDIA
CULTURES OF INDIACULTURES OF INDIA
CULTURES OF INDIA
 
India Presentation
India PresentationIndia Presentation
India Presentation
 
Indian culture
Indian cultureIndian culture
Indian culture
 

Similar to Java DataBase Connectivity API (JDBC API)

Jdbc
JdbcJdbc
Advance Java Practical file
Advance Java Practical fileAdvance Java Practical file
Advance Java Practical file
varun arora
 
03-JDBC.pptx
03-JDBC.pptx03-JDBC.pptx
03-JDBC.pptx
HachaluHaile
 
jdbc_presentation.ppt
jdbc_presentation.pptjdbc_presentation.ppt
jdbc_presentation.ppt
DrMeenakshiS
 
Java Database Connectivity
Java Database ConnectivityJava Database Connectivity
Java Database Connectivity
backdoor
 
Jdbc connectivity
Jdbc connectivityJdbc connectivity
Jdbc connectivity
arikazukito
 
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
 
4-INTERDUCATION TO JDBC-2019.ppt
4-INTERDUCATION TO JDBC-2019.ppt4-INTERDUCATION TO JDBC-2019.ppt
4-INTERDUCATION TO JDBC-2019.ppt
NaveenKumar648465
 
JDBC
JDBCJDBC
Assignment#10
Assignment#10Assignment#10
Assignment#10
Sunita Milind Dol
 
JDBC with MySQL.pdf
JDBC with MySQL.pdfJDBC with MySQL.pdf
JDBC with MySQL.pdf
Arumugam90
 
JDBC with MySQL.pdf
JDBC with MySQL.pdfJDBC with MySQL.pdf
JDBC with MySQL.pdf
Arumugam90
 
Java database connectivity with MySql
Java database connectivity with MySqlJava database connectivity with MySql
Java database connectivity with MySql
Dhyey Dattani
 
JDBC
JDBCJDBC
Jdbc (database in java)
Jdbc (database in java)Jdbc (database in java)
Jdbc (database in java)
Maher Abdo
 
Java database connectivity
Java database connectivityJava database connectivity
Java database connectivity
Vaishali Modi
 
Jdbc introduction
Jdbc introductionJdbc introduction
Jdbc introduction
Rakesh Kumar Ray
 
Java jdbc
Java jdbcJava jdbc
Java jdbc
Arati Gadgil
 
Overview Of JDBC
Overview Of JDBCOverview Of JDBC
Overview Of JDBC
Mindfire Solutions
 
Core jdbc basics
Core jdbc basicsCore jdbc basics
Core jdbc basics
Sourabrata Mukherjee
 

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

Jdbc
JdbcJdbc
Jdbc
 
Advance Java Practical file
Advance Java Practical fileAdvance Java Practical file
Advance Java Practical file
 
03-JDBC.pptx
03-JDBC.pptx03-JDBC.pptx
03-JDBC.pptx
 
jdbc_presentation.ppt
jdbc_presentation.pptjdbc_presentation.ppt
jdbc_presentation.ppt
 
Java Database Connectivity
Java Database ConnectivityJava Database Connectivity
Java Database Connectivity
 
Jdbc connectivity
Jdbc connectivityJdbc connectivity
Jdbc connectivity
 
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
 
4-INTERDUCATION TO JDBC-2019.ppt
4-INTERDUCATION TO JDBC-2019.ppt4-INTERDUCATION TO JDBC-2019.ppt
4-INTERDUCATION TO JDBC-2019.ppt
 
JDBC
JDBCJDBC
JDBC
 
Assignment#10
Assignment#10Assignment#10
Assignment#10
 
JDBC with MySQL.pdf
JDBC with MySQL.pdfJDBC with MySQL.pdf
JDBC with MySQL.pdf
 
JDBC with MySQL.pdf
JDBC with MySQL.pdfJDBC with MySQL.pdf
JDBC with MySQL.pdf
 
Java database connectivity with MySql
Java database connectivity with MySqlJava database connectivity with MySql
Java database connectivity with MySql
 
JDBC
JDBCJDBC
JDBC
 
Jdbc (database in java)
Jdbc (database in java)Jdbc (database in java)
Jdbc (database in java)
 
Java database connectivity
Java database connectivityJava database connectivity
Java database connectivity
 
Jdbc introduction
Jdbc introductionJdbc introduction
Jdbc introduction
 
Java jdbc
Java jdbcJava jdbc
Java jdbc
 
Overview Of JDBC
Overview Of JDBCOverview Of JDBC
Overview Of JDBC
 
Core jdbc basics
Core jdbc basicsCore jdbc basics
Core jdbc basics
 

Recently uploaded

Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
mamunhossenbd75
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
University of Maribor
 
Wearable antenna for antenna applications
Wearable antenna for antenna applicationsWearable antenna for antenna applications
Wearable antenna for antenna applications
Madhumitha Jayaram
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
Series of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.pptSeries of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.ppt
PauloRodrigues104553
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
JamalHussainArman
 
Exception Handling notes in java exception
Exception Handling notes in java exceptionException Handling notes in java exception
Exception Handling notes in java exception
Ratnakar Mikkili
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
Dr Ramhari Poudyal
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
heavyhaig
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
NidhalKahouli2
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
KrishnaveniKrishnara1
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
RadiNasr
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
anoopmanoharan2
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
Madan Karki
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
mahammadsalmanmech
 

Recently uploaded (20)

Heat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation pptHeat Resistant Concrete Presentation ppt
Heat Resistant Concrete Presentation ppt
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
 
Wearable antenna for antenna applications
Wearable antenna for antenna applicationsWearable antenna for antenna applications
Wearable antenna for antenna applications
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
Series of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.pptSeries of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.ppt
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
 
Exception Handling notes in java exception
Exception Handling notes in java exceptionException Handling notes in java exception
Exception Handling notes in java exception
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
Question paper of renewable energy sources
Question paper of renewable energy sourcesQuestion paper of renewable energy sources
Question paper of renewable energy sources
 

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