SlideShare a Scribd company logo
JDBC
Dev Adnani IU1983830001
JAVA DATABASE CONN.
Contents of the
Presentation
What Is JDBC
JDBC Architecture
What Is JDBC Driver
Types of JDBC Drivers
Configuration for JDBC connection
Configuration Properties For JDBC connection
Step for connection JDBC connection
What Is JDBC ?
JDBC == Java Database Connectivity
JDBC is used to connect java application with database.
JDBC is an API used to communicate Java application to database in database independent
and platform independent manner.
It provides classes and interfaces to connect or communicate Java application with database.
OTHER
MySQL
ORACLE
JDBC API
Java
Application
JDBC Architecture
JDBC
Driver
Manager
Driver
Driver
Driver
JDBC Driver
JDBC DRIVER is software component enabling a java
application to interact with a database.
It handles the communication with the database
server(oracle/mySQL).
we direct interect with the driver very rerely.
JDBC - ODBC (Bridge Driver)
Native - API Driver ( Partially java Driver)
Network Protocol Driver( Fully java Driver)
Thin Driver (Fully java Driver )
Type of JDBC driver!!
JDBC - ODBC (BRIDGE DRIVER)
Easy to use.
Can be easily connected to any database.
Performance degraded because JDBC method call is converted into the ODBC
function calls.
The ODBC driver needs to be installed on the client machine.
The JDBC-ODBC bridge driver uses ODBC driver to connect to the database.
The JDBC-ODBC bridge driver converts JDBC method calls into the ODBC function calls.
This is now discouraged because of thin driver.
Advantages:
Disadvantages:
NATIVE-API DRIVER
Performance upgraded than JDBC-ODBC bridge driver
The Native driver needs to be installed on the each client machine.
The Vendor client library needs to be installed on client machine
The Native API driver uses the client-side libraries of the database.
The driver converts JDBC method calls into native calls of the database API.
Advantage:
Disadvantage:
NETWORK PROTOCOL DRIVER
No client side library is required because of application server that can perform many tasks like
auditing, load balancing, logging etc.
Requires database-specific coding to be done in the middle tier.
Maintenance of Network Protocol driver becomes costly because it requires database-specific
coding to be done in the middle tier
The Network Protocol driver uses middleware (application server) that converts JDBC calls directly or
indirectly into the vendor-specific database protocol. It is fully written in java.
Advantage:
Disadvantages:
THIN DRIVER
Better performance.
No software is required .
Drivers depends on the Database.
The thin driver converts JDBC calls into the vendor-specific database protocol.
It is fully written in Java language.
Advantage:
Disadvantage:
Configuration Properties For JDBC connection
Driver Manager
Connection
Prepared Statement
Result Set
SQLException
DRIVER MANAGER
It matches connection requests from the java
application with the proper database driver using
communication sub-protocol.
The first driver that recognize certain sub-
protocol under JDBC will be used to establish a
database connection.
CONNECTION
Connection interface has all methods for contacting a database
The connection object represent communication context.
All communication with database is through connection object only.
PREPARED STATEMENT
Prepared Statement is an interface for representing SQL statement.
SQL statement is Precompiled and stored in a Prepared Statement object
Object can then be used efficiently execute this statement multiple time
RESULT SET
ResultSet - RS is an interface to represent a database table
These objects holds data retrieved from a database after you execute SQL query using
statement object.
It acts as an iterator to allow you to move through its data.
Step for JDBC connection
Loading driver
Establishing connection
Preparing statement
Executing statement
Getting result
Close DB
1. LOADING THE DRIVER
Class.forName() : Here we load the driver’s class file into memory at the
runtime. No need of using new or creation of object .The following example
uses Class.forName() to load the Oracle driver –
DriverManager.registerDriver(): DriverManager is a Java inbuilt class with a
static member register. Here we call the constructor of the driver class at
compile time . The following example uses DriverManager.registerDriver()to
register the Oracle driver –
- Class.forName(“oracle.jdbc.driver.OracleDriver”);
- DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
2. CREATE THE CONNECTIONS
Connection con = DriverManager.getConnection(url,user,password)
user – username from which your sql command prompt can be accessed.
password – password from which your sql command prompt can be accessed.
url : Uniform Resource Locator. It can be created as follows:
String url = “ jdbc:oracle:thin:@localhost:1521:xe”
3. CREATE A STATEMENT
Once a connection is established you can interact with the database. The
JDBCStatement, CallableStatement, and PreparedStatement interfaces define
the methods that enable you to send SQL commands and receive data from
your database.
Statement st = con.createStatement();
4. EXECUTE THE QUERY
Query for updating / inserting table in a database.
Query for retrieving data .
The executeQuery() method of Statement interface is used to execute queries
of retrieving values from the database. This method returns the object of
ResultSet that can be used to get all the records of a table.
ResultSet rset = null;
rset = st.executeQuery("select last_name, first_name from person");
5.CLOSE THE CONNECTIONS
we have sent the data to the specified location and now we are at the verge of
completion of our task .
By closing connection, objects of Statement and ResultSet will be closed
automatically. The close() method of Connection interface is used to close the
connection.
con.close();
Thank You
Any Questions?
ADNANI DEV
IU1983830001
Ad

More Related Content

What's hot (20)

Spring Framework
Spring Framework  Spring Framework
Spring Framework
tola99
 
Introduction to Spring's Dependency Injection
Introduction to Spring's Dependency InjectionIntroduction to Spring's Dependency Injection
Introduction to Spring's Dependency Injection
Richard Paul
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
Java2Blog
 
History Of JAVA
History Of JAVAHistory Of JAVA
History Of JAVA
ARSLANAHMED107
 
JDBC
JDBCJDBC
JDBC
People Strategists
 
Java static keyword
Java static keywordJava static keyword
Java static keyword
Lovely Professional University
 
Java RMI
Java RMIJava RMI
Java RMI
Ankit Desai
 
Introduction to Basic Java Versions and their features
Introduction to Basic Java Versions and their featuresIntroduction to Basic Java Versions and their features
Introduction to Basic Java Versions and their features
Akash Badone
 
JDBC Java Database Connectivity
JDBC Java Database ConnectivityJDBC Java Database Connectivity
JDBC Java Database Connectivity
Ranjan Kumar
 
Generics in java
Generics in javaGenerics in java
Generics in java
suraj pandey
 
This keyword in java
This keyword in javaThis keyword in java
This keyword in java
Hitesh Kumar
 
Java Presentation
Java PresentationJava Presentation
Java Presentation
pm2214
 
QSpiders - Jdk Jvm Jre and Jit
QSpiders - Jdk Jvm Jre and JitQSpiders - Jdk Jvm Jre and Jit
QSpiders - Jdk Jvm Jre and Jit
Qspiders - Software Testing Training Institute
 
Java multi threading
Java multi threadingJava multi threading
Java multi threading
Raja Sekhar
 
JDK,JRE,JVM
JDK,JRE,JVMJDK,JRE,JVM
JDK,JRE,JVM
Cognizant
 
JDBC – Java Database Connectivity
JDBC – Java Database ConnectivityJDBC – Java Database Connectivity
JDBC – Java Database Connectivity
Information Technology
 
Java IO
Java IOJava IO
Java IO
UTSAB NEUPANE
 
Java 8 - Features Overview
Java 8 - Features OverviewJava 8 - Features Overview
Java 8 - Features Overview
Sergii Stets
 
C# String
C# StringC# String
C# String
Raghuveer Guthikonda
 
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slidesSpring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Hitesh-Java
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
tola99
 
Introduction to Spring's Dependency Injection
Introduction to Spring's Dependency InjectionIntroduction to Spring's Dependency Injection
Introduction to Spring's Dependency Injection
Richard Paul
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
Java2Blog
 
Introduction to Basic Java Versions and their features
Introduction to Basic Java Versions and their featuresIntroduction to Basic Java Versions and their features
Introduction to Basic Java Versions and their features
Akash Badone
 
JDBC Java Database Connectivity
JDBC Java Database ConnectivityJDBC Java Database Connectivity
JDBC Java Database Connectivity
Ranjan Kumar
 
This keyword in java
This keyword in javaThis keyword in java
This keyword in java
Hitesh Kumar
 
Java Presentation
Java PresentationJava Presentation
Java Presentation
pm2214
 
Java multi threading
Java multi threadingJava multi threading
Java multi threading
Raja Sekhar
 
Java 8 - Features Overview
Java 8 - Features OverviewJava 8 - Features Overview
Java 8 - Features Overview
Sergii Stets
 
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slidesSpring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Hitesh-Java
 

Similar to JDBC : Java Database Connectivity (20)

Jdbc introduction
Jdbc introductionJdbc introduction
Jdbc introduction
Rakesh Kumar Ray
 
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 Java Database Connectivity ujjwal matoliya jdbc.pptx
 jdbc Java Database Connectivity ujjwal matoliya jdbc.pptx jdbc Java Database Connectivity ujjwal matoliya jdbc.pptx
jdbc Java Database Connectivity ujjwal matoliya jdbc.pptx
ujjwalmatoliya
 
chapter 5 java.pptx
chapter 5  java.pptxchapter 5  java.pptx
chapter 5 java.pptx
BekiTube
 
creating jdbc connection
creating jdbc connectioncreating jdbc connection
creating jdbc connection
Paneliya Prince
 
creating jdbc connection
creating jdbc connectioncreating jdbc connection
creating jdbc connection
Paneliya Prince
 
JDBC-Introduction
JDBC-IntroductionJDBC-Introduction
JDBC-Introduction
Mythili Shankar
 
Basic Java Database Connectivity(JDBC)
Basic Java Database Connectivity(JDBC)Basic Java Database Connectivity(JDBC)
Basic Java Database Connectivity(JDBC)
suraj pandey
 
Fundamentals of JDBC
Fundamentals of JDBCFundamentals of JDBC
Fundamentals of JDBC
Jainul Musani
 
Unit 5-jdbc2
Unit 5-jdbc2Unit 5-jdbc2
Unit 5-jdbc2
msafad
 
Chapter 5 JDBC.pdf for stufent of computer andtudent It s
Chapter 5 JDBC.pdf for stufent of computer andtudent  It sChapter 5 JDBC.pdf for stufent of computer andtudent  It s
Chapter 5 JDBC.pdf for stufent of computer andtudent It s
anuwaradisu19
 
Jdbc architecture and driver types ppt
Jdbc architecture and driver types pptJdbc architecture and driver types ppt
Jdbc architecture and driver types ppt
kamal kotecha
 
unit8_jdbc.pdf mysql and java jdbc connection
unit8_jdbc.pdf mysql and java jdbc connectionunit8_jdbc.pdf mysql and java jdbc connection
unit8_jdbc.pdf mysql and java jdbc connection
Indu32
 
JDBC java database connectivity with dbms
JDBC java database connectivity with dbmsJDBC java database connectivity with dbms
JDBC java database connectivity with dbms
KhyalNayak
 
Rajesh jdbc
Rajesh   jdbcRajesh   jdbc
Rajesh jdbc
Aditya Sharma
 
jdbc
jdbcjdbc
jdbc
Gayatri Patel
 
Java jdbc
Java jdbcJava jdbc
Java jdbc
AliHusseini14
 
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
 
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 Java Database Connectivity ujjwal matoliya jdbc.pptx
 jdbc Java Database Connectivity ujjwal matoliya jdbc.pptx jdbc Java Database Connectivity ujjwal matoliya jdbc.pptx
jdbc Java Database Connectivity ujjwal matoliya jdbc.pptx
ujjwalmatoliya
 
chapter 5 java.pptx
chapter 5  java.pptxchapter 5  java.pptx
chapter 5 java.pptx
BekiTube
 
creating jdbc connection
creating jdbc connectioncreating jdbc connection
creating jdbc connection
Paneliya Prince
 
creating jdbc connection
creating jdbc connectioncreating jdbc connection
creating jdbc connection
Paneliya Prince
 
Basic Java Database Connectivity(JDBC)
Basic Java Database Connectivity(JDBC)Basic Java Database Connectivity(JDBC)
Basic Java Database Connectivity(JDBC)
suraj pandey
 
Fundamentals of JDBC
Fundamentals of JDBCFundamentals of JDBC
Fundamentals of JDBC
Jainul Musani
 
Unit 5-jdbc2
Unit 5-jdbc2Unit 5-jdbc2
Unit 5-jdbc2
msafad
 
Chapter 5 JDBC.pdf for stufent of computer andtudent It s
Chapter 5 JDBC.pdf for stufent of computer andtudent  It sChapter 5 JDBC.pdf for stufent of computer andtudent  It s
Chapter 5 JDBC.pdf for stufent of computer andtudent It s
anuwaradisu19
 
Jdbc architecture and driver types ppt
Jdbc architecture and driver types pptJdbc architecture and driver types ppt
Jdbc architecture and driver types ppt
kamal kotecha
 
unit8_jdbc.pdf mysql and java jdbc connection
unit8_jdbc.pdf mysql and java jdbc connectionunit8_jdbc.pdf mysql and java jdbc connection
unit8_jdbc.pdf mysql and java jdbc connection
Indu32
 
JDBC java database connectivity with dbms
JDBC java database connectivity with dbmsJDBC java database connectivity with dbms
JDBC java database connectivity with dbms
KhyalNayak
 
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
 
Ad

More from DevAdnani (8)

Joker Analysis
Joker AnalysisJoker Analysis
Joker Analysis
DevAdnani
 
Coding principles
Coding principles Coding principles
Coding principles
DevAdnani
 
Amazon Case Study 2021
Amazon Case Study 2021Amazon Case Study 2021
Amazon Case Study 2021
DevAdnani
 
Transport layer security
Transport layer securityTransport layer security
Transport layer security
DevAdnani
 
Data mining
 Data mining Data mining
Data mining
DevAdnani
 
Abstarction & Encapsulation
Abstarction & EncapsulationAbstarction & Encapsulation
Abstarction & Encapsulation
DevAdnani
 
Security issues in os
Security issues in osSecurity issues in os
Security issues in os
DevAdnani
 
Women entrepreneurship
Women entrepreneurship Women entrepreneurship
Women entrepreneurship
DevAdnani
 
Joker Analysis
Joker AnalysisJoker Analysis
Joker Analysis
DevAdnani
 
Coding principles
Coding principles Coding principles
Coding principles
DevAdnani
 
Amazon Case Study 2021
Amazon Case Study 2021Amazon Case Study 2021
Amazon Case Study 2021
DevAdnani
 
Transport layer security
Transport layer securityTransport layer security
Transport layer security
DevAdnani
 
Data mining
 Data mining Data mining
Data mining
DevAdnani
 
Abstarction & Encapsulation
Abstarction & EncapsulationAbstarction & Encapsulation
Abstarction & Encapsulation
DevAdnani
 
Security issues in os
Security issues in osSecurity issues in os
Security issues in os
DevAdnani
 
Women entrepreneurship
Women entrepreneurship Women entrepreneurship
Women entrepreneurship
DevAdnani
 
Ad

Recently uploaded (20)

"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit..."Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
AlionaBujoreanu
 
materi 3D Augmented Reality dengan assemblr
materi 3D Augmented Reality dengan assemblrmateri 3D Augmented Reality dengan assemblr
materi 3D Augmented Reality dengan assemblr
fatikhatunnajikhah1
 
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
businessweekghana
 
GENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdf
GENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdfGENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdf
GENERAL QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 4 MARCH 2025 .pdf
Quiz Club of PSG College of Arts & Science
 
libbys peer assesment.docx..............
libbys peer assesment.docx..............libbys peer assesment.docx..............
libbys peer assesment.docx..............
19lburrell
 
2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx
mansk2
 
INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024
INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024
INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024
Quiz Club of PSG College of Arts & Science
 
PUBH1000 Slides - Module 11: Governance for Health
PUBH1000 Slides - Module 11: Governance for HealthPUBH1000 Slides - Module 11: Governance for Health
PUBH1000 Slides - Module 11: Governance for Health
JonathanHallett4
 
How to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 WebsiteHow to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 Website
Celine George
 
Pope Leo XIV, the first Pope from North America.pptx
Pope Leo XIV, the first Pope from North America.pptxPope Leo XIV, the first Pope from North America.pptx
Pope Leo XIV, the first Pope from North America.pptx
Martin M Flynn
 
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
parmarjuli1412
 
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdfAntepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Dr H.K. Cheema
 
How to Add Button in Chatter in Odoo 18 - Odoo Slides
How to Add Button in Chatter in Odoo 18 - Odoo SlidesHow to Add Button in Chatter in Odoo 18 - Odoo Slides
How to Add Button in Chatter in Odoo 18 - Odoo Slides
Celine George
 
Rebuilding the library community in a post-Twitter world
Rebuilding the library community in a post-Twitter worldRebuilding the library community in a post-Twitter world
Rebuilding the library community in a post-Twitter world
Ned Potter
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-14-2025 .pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-14-2025  .pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-14-2025  .pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-14-2025 .pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
How to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale OrderHow to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale Order
Celine George
 
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales moduleHow To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
Celine George
 
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit..."Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
AlionaBujoreanu
 
materi 3D Augmented Reality dengan assemblr
materi 3D Augmented Reality dengan assemblrmateri 3D Augmented Reality dengan assemblr
materi 3D Augmented Reality dengan assemblr
fatikhatunnajikhah1
 
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
businessweekghana
 
libbys peer assesment.docx..............
libbys peer assesment.docx..............libbys peer assesment.docx..............
libbys peer assesment.docx..............
19lburrell
 
2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx
mansk2
 
PUBH1000 Slides - Module 11: Governance for Health
PUBH1000 Slides - Module 11: Governance for HealthPUBH1000 Slides - Module 11: Governance for Health
PUBH1000 Slides - Module 11: Governance for Health
JonathanHallett4
 
How to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 WebsiteHow to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 Website
Celine George
 
Pope Leo XIV, the first Pope from North America.pptx
Pope Leo XIV, the first Pope from North America.pptxPope Leo XIV, the first Pope from North America.pptx
Pope Leo XIV, the first Pope from North America.pptx
Martin M Flynn
 
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
parmarjuli1412
 
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdfAntepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Dr H.K. Cheema
 
How to Add Button in Chatter in Odoo 18 - Odoo Slides
How to Add Button in Chatter in Odoo 18 - Odoo SlidesHow to Add Button in Chatter in Odoo 18 - Odoo Slides
How to Add Button in Chatter in Odoo 18 - Odoo Slides
Celine George
 
Rebuilding the library community in a post-Twitter world
Rebuilding the library community in a post-Twitter worldRebuilding the library community in a post-Twitter world
Rebuilding the library community in a post-Twitter world
Ned Potter
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
How to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale OrderHow to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale Order
Celine George
 
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales moduleHow To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
Celine George
 

JDBC : Java Database Connectivity

  • 2. Contents of the Presentation What Is JDBC JDBC Architecture What Is JDBC Driver Types of JDBC Drivers Configuration for JDBC connection Configuration Properties For JDBC connection Step for connection JDBC connection
  • 3. What Is JDBC ? JDBC == Java Database Connectivity JDBC is used to connect java application with database. JDBC is an API used to communicate Java application to database in database independent and platform independent manner. It provides classes and interfaces to connect or communicate Java application with database.
  • 5. JDBC Driver JDBC DRIVER is software component enabling a java application to interact with a database. It handles the communication with the database server(oracle/mySQL). we direct interect with the driver very rerely.
  • 6. JDBC - ODBC (Bridge Driver) Native - API Driver ( Partially java Driver) Network Protocol Driver( Fully java Driver) Thin Driver (Fully java Driver ) Type of JDBC driver!!
  • 7. JDBC - ODBC (BRIDGE DRIVER) Easy to use. Can be easily connected to any database. Performance degraded because JDBC method call is converted into the ODBC function calls. The ODBC driver needs to be installed on the client machine. The JDBC-ODBC bridge driver uses ODBC driver to connect to the database. The JDBC-ODBC bridge driver converts JDBC method calls into the ODBC function calls. This is now discouraged because of thin driver. Advantages: Disadvantages:
  • 8. NATIVE-API DRIVER Performance upgraded than JDBC-ODBC bridge driver The Native driver needs to be installed on the each client machine. The Vendor client library needs to be installed on client machine The Native API driver uses the client-side libraries of the database. The driver converts JDBC method calls into native calls of the database API. Advantage: Disadvantage:
  • 9. NETWORK PROTOCOL DRIVER No client side library is required because of application server that can perform many tasks like auditing, load balancing, logging etc. Requires database-specific coding to be done in the middle tier. Maintenance of Network Protocol driver becomes costly because it requires database-specific coding to be done in the middle tier The Network Protocol driver uses middleware (application server) that converts JDBC calls directly or indirectly into the vendor-specific database protocol. It is fully written in java. Advantage: Disadvantages:
  • 10. THIN DRIVER Better performance. No software is required . Drivers depends on the Database. The thin driver converts JDBC calls into the vendor-specific database protocol. It is fully written in Java language. Advantage: Disadvantage:
  • 11. Configuration Properties For JDBC connection Driver Manager Connection Prepared Statement Result Set SQLException
  • 12. DRIVER MANAGER It matches connection requests from the java application with the proper database driver using communication sub-protocol. The first driver that recognize certain sub- protocol under JDBC will be used to establish a database connection.
  • 13. CONNECTION Connection interface has all methods for contacting a database The connection object represent communication context. All communication with database is through connection object only.
  • 14. PREPARED STATEMENT Prepared Statement is an interface for representing SQL statement. SQL statement is Precompiled and stored in a Prepared Statement object Object can then be used efficiently execute this statement multiple time
  • 15. RESULT SET ResultSet - RS is an interface to represent a database table These objects holds data retrieved from a database after you execute SQL query using statement object. It acts as an iterator to allow you to move through its data.
  • 16. Step for JDBC connection Loading driver Establishing connection Preparing statement Executing statement Getting result Close DB
  • 17. 1. LOADING THE DRIVER Class.forName() : Here we load the driver’s class file into memory at the runtime. No need of using new or creation of object .The following example uses Class.forName() to load the Oracle driver – DriverManager.registerDriver(): DriverManager is a Java inbuilt class with a static member register. Here we call the constructor of the driver class at compile time . The following example uses DriverManager.registerDriver()to register the Oracle driver – - Class.forName(“oracle.jdbc.driver.OracleDriver”); - DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
  • 18. 2. CREATE THE CONNECTIONS Connection con = DriverManager.getConnection(url,user,password) user – username from which your sql command prompt can be accessed. password – password from which your sql command prompt can be accessed. url : Uniform Resource Locator. It can be created as follows: String url = “ jdbc:oracle:thin:@localhost:1521:xe”
  • 19. 3. CREATE A STATEMENT Once a connection is established you can interact with the database. The JDBCStatement, CallableStatement, and PreparedStatement interfaces define the methods that enable you to send SQL commands and receive data from your database. Statement st = con.createStatement();
  • 20. 4. EXECUTE THE QUERY Query for updating / inserting table in a database. Query for retrieving data . The executeQuery() method of Statement interface is used to execute queries of retrieving values from the database. This method returns the object of ResultSet that can be used to get all the records of a table. ResultSet rset = null; rset = st.executeQuery("select last_name, first_name from person");
  • 21. 5.CLOSE THE CONNECTIONS we have sent the data to the specified location and now we are at the verge of completion of our task . By closing connection, objects of Statement and ResultSet will be closed automatically. The close() method of Connection interface is used to close the connection. con.close();
  翻译: