SlideShare a Scribd company logo
2
Most read
3
Most read
15
Most read
Advanced Programming
Java Database Connectivity
Gera
2020
1
Introduction
•A database is an organized collection of data.
•There are many different strategies for organizing
data to facilitate easy access and manipulation.
•A database management system (DBMS) provides
mechanisms for storing, organizing, retrieving and
modifying data for many users.
•Database management systems allow for the
access and storage of data without concern for the
internal representation of data. 2
Java Database Connectivity (JDBC)
•JDBC is Java application programming
interface that allows the Java programmers to
access database management system from
the java code.
•It was developed by JavaSoft, a subsidiary of
Sun Microsystems.
•It is a java API which enables the java
programs to execute SQL statements.
3
Java Database Connectivity (JDBC)…
• JDBC provides methods for querying and updating the
data in Relational Database Management system such
as SQL, Oracle etc.
• Generally all Relational Database Management
System supports SQL and we all know that Java is
platform independent.
• So JDBC makes it possible to write a single database
application that can run on different platforms and
interact with different Database Management
Systems. 4
The Structured Query Language SQL
•JDBC is an interface to SQL, which is the interface
to essentially all modern relational databases.
•Desktop databases usually have a graphical user
interfaces that lets users manipulate the data
directly, but server-based databases are accessed
purely through SQL.
•Most desktop databases have a SQL interface as
well, but it often does not support the full range of
ANSI SQL92 features, the current standard for SQL.
5
SQL Basic SELECT Query
• Let us consider several SQL queries that extract information from
database books.
• A SQL query “selects” rows and columns from one or more tables
in a database. Such selections are performed by queries with the
SELECT keyword.
• The basic form of a SELECT query is
SELECT * FROM tableName
in which the asterisk (*) indicates that all columns from the
tableName table should be retrieved.
• For example, to retrieve all the data in the authors table, use
SELECT * FROM authors 6
SQL Basic SELECT Query
• For example, to retrieve only the columns authorID and lastName
for all rows in the authors table, use the query
SELECT authorID, lastName FROM authors
This query returns the data listed as following sample:
7
SQL Basic SELECT Query
• SQL query keywords
8
Installing JDBC
•First, you need a database program that is
compatible with JDBC.
•You will also need to create a database for your
experimental use.
•We assume you will call this database COREJAVA.
•Create a new database, or have your database
administrator create one with the appropriate
permissions. You need to be able to create,
update, and drop tables. 9
Installing JDBC…
• If you have never installed a client/server database
before, you may find that setting up the database is
somewhat complex and that it can be difficult to
diagnose the cause for failure.
• One alternative is to install a pure Java database such
as Cloudscape (http://www.cloudscape.com),
PointBase (http://www.pointbase.com), or InstantDB
(http://www.lutris.com/products/instantDB).
• These databases are less powerful but simple to set
up. 10
Installing JDBC…
•Essentially all database vendors already have
JDBC drivers.
•You need to locate the vendor's instructions
to load the driver into your program and to
connect to the database.
11
Basic JDBC Programming Concepts
•Programming with the JDBC classes is, by
design, not very different from programming
with the usual Java platform classes:
•You build objects from the JDBC core classes,
extending them by inheritance if need be.
12
Components of JDBC
1. The JDBC API.
2. The JDBC Driver Manager.
3. The JDBC Test Suite.
4. The JDBC-ODBC Bridge.
13
JDBC API
• The JDBC API provides the facility for accessing the
relational database from the Java programming
language.
• The user not only execute the SQL statements, retrieve
results, and update the data but can also access it
anywhere within a network because of it's "Write Once,
Run Anywhere" (WORA) capabilities.
• Due to JDBC API technology, user can also access other
tabular data sources like spreadsheets or flat files even in
the a heterogeneous environment.
14
JDBC API…
• JDBC application programming interface is a part of the
Java platform that have included Java SE and Java EE in
itself.
• The latest version of JDBC 4.0 application programming
interface is divided into two packages.
i) java.sql.
ii) javax.sql.
• Java SE and Java EE platforms are included in both the
packages.
15
JDBC Driver
• A JDBC driver translates standard JDBC calls into a
network or database protocol OR into a database library
API call that facilitates communication with the
database.
• There are four distinct types of JDBC drivers.
1. JDBC-ODBC Bridge + ODBC Driver, also called as Type1
2. Native API , Pure/partly Java Driver, also called Type 2.
3. JDBC –Net Pure Java Driver, also called Type 3.
4. Native Protocol , Pure Java Driver, also called Type 4.
16
JDBC Driver Manager
• The JDBC Driver Manager is a very important class that
defines objects which connect Java applications to a
JDBC driver.
• Usually Driver Manager is the backbone of the JDBC
architecture.
• It's very simple and small that is used to provide a means
of managing the different types of JDBC database driver
running on an application.
17
JDBC Driver Manager…
•The main responsibility of JDBC database driver is
to load all the drivers found in the system properly
as well as to select the most appropriate driver
from opening a connection to a database.
•The Driver Manager also helps to select the most
appropriate driver from the previously loaded
drivers when a new open database is connected.
18
JDBC Test Suite
•The function of JDBC driver test suite is to make
ensure that the JDBC drivers will run user's
program or not .
•The test suite of JDBC application program
interface is very useful for testing a driver based
on JDBC technology during testing period.
•It ensures the requirement of Java Platform
Enterprise Edition (J2EE).
19
ODBC (Open Data Base Connectivity)
•Open DataBase Connectivity is similar to Java
Database Connectivity which is used for
accessing and managing database, but the
difference is that JDBC is designed specifically
for Java programs, whereas ODBC is not
depended upon any language.
20
JDBC-ODBC Bridge
•The JDBC-ODBC bridge, also known as JDBC type 1
driver is a database driver that utilize the ODBC
driver to connect the database.
•This driver translates JDBC method calls into ODBC
function calls.
•The Bridge implements Jdbc for any database for
which an Odbc driver is available.
•The Bridge is always implemented as the
sun.jdbc.odbc Java package and it contains a 21
Functions of JDBC-ODBC Bridge
•Translates query obtained by JDBC into
corresponding ODBC query, which is then handled
by the ODBC driver.
•Sun provides a JDBC-ODBC Bridge driver.
sun.jdbc.odbc.JdbcOdbcDriver. This driver is
native code and not Java, and is closed source.
•Client -> JDBC Driver -> ODBC Driver -> Database
•There is some overhead associated with the
translation work to go from JDBC to ODBC. 22
Components of JDBC
•This first two component of JDBC, the JDBC API
and the JDBC Driver Manager manages to connect
to the database and then build a java program that
utilizes SQL commands to communicate with any
RDBMS.
•On the other hand, the last two components are
used to communicate with ODBC or to test web
application in the specialized environment.
23
References
➢S. Horstmann and Gary Cornell, Core Java 2 – Volume II-
Advanced Features, Sun Microsystems Press
➢Harvey M. Deitel and Paul J. Deitel, Java How to
Program, Deitel & Associates
➢Nitesh Kukreja and Pooja Talreja, “An introduction to
java connectivity (JDBC),”
24
Gerabirhan Paulos
ToCourseInfo@gmail.com

More Related Content

What's hot (20)

358 33 powerpoint-slides_10-trees_chapter-10
358 33 powerpoint-slides_10-trees_chapter-10
sumitbardhan
 
Basic Concept of Database
Basic Concept of Database
Marlon Jamera
 
stack and queue array implementation in java.
stack and queue array implementation in java.
CIIT Atd.
 
Introduction to Database Management Systems: Structure, Applications, and Key...
Introduction to Database Management Systems: Structure, Applications, and Key...
Mahmud Hasan Tanvir
 
B and B+ tree
B and B+ tree
Ashish Arun
 
SQL Queries Information
SQL Queries Information
Nishant Munjal
 
Er diagram
Er diagram
Sabana Maharjan
 
Normalization
Normalization
meet darji
 
Assemblers: Ch03
Assemblers: Ch03
desta_gebre
 
Database architecture
Database architecture
VENNILAV6
 
Binary tree
Binary tree
Rajendran
 
Tree terminology and introduction to binary tree
Tree terminology and introduction to binary tree
jyoti_lakhani
 
Theory of dependencies in relational database
Theory of dependencies in relational database
Jyoti Ranjan Pattnaik
 
2 3 Trees Algorithm - Data Structure
2 3 Trees Algorithm - Data Structure
Tish997
 
Web servers for the Internet of Things
Web servers for the Internet of Things
Alexandru Radovici
 
Data Structures and Algorithms
Data Structures and Algorithms
Pierre Vigneras
 
Previous question papers of Database Management System (DBMS) By SHABEEB
Previous question papers of Database Management System (DBMS) By SHABEEB
Shabeeb Shabi
 
IoT in Healthcare: How Internet of Things (IoT) is Revolutionizing the Medica...
IoT in Healthcare: How Internet of Things (IoT) is Revolutionizing the Medica...
PritiranjanMaharana1
 
Fundamentals of Database system
Fundamentals of Database system
philipsinter
 
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
Vraj Patel
 
358 33 powerpoint-slides_10-trees_chapter-10
358 33 powerpoint-slides_10-trees_chapter-10
sumitbardhan
 
Basic Concept of Database
Basic Concept of Database
Marlon Jamera
 
stack and queue array implementation in java.
stack and queue array implementation in java.
CIIT Atd.
 
Introduction to Database Management Systems: Structure, Applications, and Key...
Introduction to Database Management Systems: Structure, Applications, and Key...
Mahmud Hasan Tanvir
 
SQL Queries Information
SQL Queries Information
Nishant Munjal
 
Assemblers: Ch03
Assemblers: Ch03
desta_gebre
 
Database architecture
Database architecture
VENNILAV6
 
Tree terminology and introduction to binary tree
Tree terminology and introduction to binary tree
jyoti_lakhani
 
Theory of dependencies in relational database
Theory of dependencies in relational database
Jyoti Ranjan Pattnaik
 
2 3 Trees Algorithm - Data Structure
2 3 Trees Algorithm - Data Structure
Tish997
 
Web servers for the Internet of Things
Web servers for the Internet of Things
Alexandru Radovici
 
Data Structures and Algorithms
Data Structures and Algorithms
Pierre Vigneras
 
Previous question papers of Database Management System (DBMS) By SHABEEB
Previous question papers of Database Management System (DBMS) By SHABEEB
Shabeeb Shabi
 
IoT in Healthcare: How Internet of Things (IoT) is Revolutionizing the Medica...
IoT in Healthcare: How Internet of Things (IoT) is Revolutionizing the Medica...
PritiranjanMaharana1
 
Fundamentals of Database system
Fundamentals of Database system
philipsinter
 
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
Vraj Patel
 

Similar to Java Database Connectivity (Advanced programming) (20)

4-INTERDUCATION TO JDBC-2019.ppt
4-INTERDUCATION TO JDBC-2019.ppt
NaveenKumar648465
 
jdbc document
jdbc document
Yamuna Devi
 
Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)
Pooja Talreja
 
Chapter_4_-_JDBC[1].pptx
Chapter_4_-_JDBC[1].pptx
BachaSirata
 
Final Database Connectivity in JAVA.ppt
Final Database Connectivity in JAVA.ppt
TabassumMaktum
 
Chap3 3 12
Chap3 3 12
Hemo Chella
 
Jdbc introduction
Jdbc introduction
Rakesh Kumar Ray
 
Jdbc sasidhar
Jdbc sasidhar
Sasidhar Kothuru
 
Advanced JAVA
Advanced JAVA
Rajvi Vaghasiya
 
JDBC java for learning java for learn.ppt
JDBC java for learning java for learn.ppt
kingkolju
 
JDBC
JDBC
People Strategists
 
JDBC.ppt
JDBC.ppt
ChagantiSahith
 
java 4 Part 1 computer science.pptx
java 4 Part 1 computer science.pptx
MUHAMMED MASHAHIL PUKKUNNUMMAL
 
open data base connectivity and java database connectivity
open data base connectivity and java database connectivity
ssuser42b933
 
java database connection (jdbc)
java database connection (jdbc)
Sanjay Gunjal
 
Jdbc 1
Jdbc 1
Mukesh Tekwani
 
Java database connectivity with MySql
Java database connectivity with MySql
Dhyey Dattani
 
Java database connectivity with MySql
Java database connectivity with MySql
Dhyey Dattani
 
Chapter 5 JDBC.pdf for stufent of computer andtudent It s
Chapter 5 JDBC.pdf for stufent of computer andtudent It s
anuwaradisu19
 
JDBC with MySQL.pdf
JDBC with MySQL.pdf
Arumugam90
 
4-INTERDUCATION TO JDBC-2019.ppt
4-INTERDUCATION TO JDBC-2019.ppt
NaveenKumar648465
 
Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)
Pooja Talreja
 
Chapter_4_-_JDBC[1].pptx
Chapter_4_-_JDBC[1].pptx
BachaSirata
 
Final Database Connectivity in JAVA.ppt
Final Database Connectivity in JAVA.ppt
TabassumMaktum
 
JDBC java for learning java for learn.ppt
JDBC java for learning java for learn.ppt
kingkolju
 
open data base connectivity and java database connectivity
open data base connectivity and java database connectivity
ssuser42b933
 
java database connection (jdbc)
java database connection (jdbc)
Sanjay Gunjal
 
Java database connectivity with MySql
Java database connectivity with MySql
Dhyey Dattani
 
Java database connectivity with MySql
Java database connectivity with MySql
Dhyey Dattani
 
Chapter 5 JDBC.pdf for stufent of computer andtudent It s
Chapter 5 JDBC.pdf for stufent of computer andtudent It s
anuwaradisu19
 
JDBC with MySQL.pdf
JDBC with MySQL.pdf
Arumugam90
 
Ad

More from Gera Paulos (20)

Networking in java, Advanced programming
Networking in java, Advanced programming
Gera Paulos
 
Remote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programming
Gera Paulos
 
Multi Threading Concept (Advanced programming)
Multi Threading Concept (Advanced programming)
Gera Paulos
 
Servlets as introduction (Advanced programming)
Servlets as introduction (Advanced programming)
Gera Paulos
 
Advanced programming ch2
Advanced programming ch2
Gera Paulos
 
Advanced programming ch1
Advanced programming ch1
Gera Paulos
 
Image restoration and enhancement #2
Image restoration and enhancement #2
Gera Paulos
 
Introduction to digital image processing #1
Introduction to digital image processing #1
Gera Paulos
 
Implement maintenance procedures
Implement maintenance procedures
Gera Paulos
 
Maintain equipment and consumables
Maintain equipment and consumables
Gera Paulos
 
Care for network and computer hardware
Care for network and computer hardware
Gera Paulos
 
Update and document operational procedures
Update and document operational procedures
Gera Paulos
 
Apply quality control
Apply quality control
Gera Paulos
 
Monitoring implementation of work plan
Monitoring implementation of work plan
Gera Paulos
 
Provide first level remote help desk support
Provide first level remote help desk support
Gera Paulos
 
Configuring and administrate server
Configuring and administrate server
Gera Paulos
 
Identifying and resolving network problems
Identifying and resolving network problems
Gera Paulos
 
Conduct / facilitate user training
Conduct / facilitate user training
Gera Paulos
 
Monitor and administer system and network
Monitor and administer system and network
Gera Paulos
 
Creating technical documents
Creating technical documents
Gera Paulos
 
Networking in java, Advanced programming
Networking in java, Advanced programming
Gera Paulos
 
Remote Method Invocation, Advanced programming
Remote Method Invocation, Advanced programming
Gera Paulos
 
Multi Threading Concept (Advanced programming)
Multi Threading Concept (Advanced programming)
Gera Paulos
 
Servlets as introduction (Advanced programming)
Servlets as introduction (Advanced programming)
Gera Paulos
 
Advanced programming ch2
Advanced programming ch2
Gera Paulos
 
Advanced programming ch1
Advanced programming ch1
Gera Paulos
 
Image restoration and enhancement #2
Image restoration and enhancement #2
Gera Paulos
 
Introduction to digital image processing #1
Introduction to digital image processing #1
Gera Paulos
 
Implement maintenance procedures
Implement maintenance procedures
Gera Paulos
 
Maintain equipment and consumables
Maintain equipment and consumables
Gera Paulos
 
Care for network and computer hardware
Care for network and computer hardware
Gera Paulos
 
Update and document operational procedures
Update and document operational procedures
Gera Paulos
 
Apply quality control
Apply quality control
Gera Paulos
 
Monitoring implementation of work plan
Monitoring implementation of work plan
Gera Paulos
 
Provide first level remote help desk support
Provide first level remote help desk support
Gera Paulos
 
Configuring and administrate server
Configuring and administrate server
Gera Paulos
 
Identifying and resolving network problems
Identifying and resolving network problems
Gera Paulos
 
Conduct / facilitate user training
Conduct / facilitate user training
Gera Paulos
 
Monitor and administer system and network
Monitor and administer system and network
Gera Paulos
 
Creating technical documents
Creating technical documents
Gera Paulos
 
Ad

Recently uploaded (20)

June Patch Tuesday
June Patch Tuesday
Ivanti
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
High Availability On-Premises FME Flow.pdf
High Availability On-Premises FME Flow.pdf
Safe Software
 
Analysis of the changes in the attitude of the news comments caused by knowin...
Analysis of the changes in the attitude of the news comments caused by knowin...
Matsushita Laboratory
 
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
Edge AI and Vision Alliance
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Safe Software
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
Supporting the NextGen 911 Digital Transformation with FME
Supporting the NextGen 911 Digital Transformation with FME
Safe Software
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
June Patch Tuesday
June Patch Tuesday
Ivanti
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
High Availability On-Premises FME Flow.pdf
High Availability On-Premises FME Flow.pdf
Safe Software
 
Analysis of the changes in the attitude of the news comments caused by knowin...
Analysis of the changes in the attitude of the news comments caused by knowin...
Matsushita Laboratory
 
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
Edge AI and Vision Alliance
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Safe Software
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
Supporting the NextGen 911 Digital Transformation with FME
Supporting the NextGen 911 Digital Transformation with FME
Safe Software
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 

Java Database Connectivity (Advanced programming)

  • 1. Advanced Programming Java Database Connectivity Gera 2020 1
  • 2. Introduction •A database is an organized collection of data. •There are many different strategies for organizing data to facilitate easy access and manipulation. •A database management system (DBMS) provides mechanisms for storing, organizing, retrieving and modifying data for many users. •Database management systems allow for the access and storage of data without concern for the internal representation of data. 2
  • 3. Java Database Connectivity (JDBC) •JDBC is Java application programming interface that allows the Java programmers to access database management system from the java code. •It was developed by JavaSoft, a subsidiary of Sun Microsystems. •It is a java API which enables the java programs to execute SQL statements. 3
  • 4. Java Database Connectivity (JDBC)… • JDBC provides methods for querying and updating the data in Relational Database Management system such as SQL, Oracle etc. • Generally all Relational Database Management System supports SQL and we all know that Java is platform independent. • So JDBC makes it possible to write a single database application that can run on different platforms and interact with different Database Management Systems. 4
  • 5. The Structured Query Language SQL •JDBC is an interface to SQL, which is the interface to essentially all modern relational databases. •Desktop databases usually have a graphical user interfaces that lets users manipulate the data directly, but server-based databases are accessed purely through SQL. •Most desktop databases have a SQL interface as well, but it often does not support the full range of ANSI SQL92 features, the current standard for SQL. 5
  • 6. SQL Basic SELECT Query • Let us consider several SQL queries that extract information from database books. • A SQL query “selects” rows and columns from one or more tables in a database. Such selections are performed by queries with the SELECT keyword. • The basic form of a SELECT query is SELECT * FROM tableName in which the asterisk (*) indicates that all columns from the tableName table should be retrieved. • For example, to retrieve all the data in the authors table, use SELECT * FROM authors 6
  • 7. SQL Basic SELECT Query • For example, to retrieve only the columns authorID and lastName for all rows in the authors table, use the query SELECT authorID, lastName FROM authors This query returns the data listed as following sample: 7
  • 8. SQL Basic SELECT Query • SQL query keywords 8
  • 9. Installing JDBC •First, you need a database program that is compatible with JDBC. •You will also need to create a database for your experimental use. •We assume you will call this database COREJAVA. •Create a new database, or have your database administrator create one with the appropriate permissions. You need to be able to create, update, and drop tables. 9
  • 10. Installing JDBC… • If you have never installed a client/server database before, you may find that setting up the database is somewhat complex and that it can be difficult to diagnose the cause for failure. • One alternative is to install a pure Java database such as Cloudscape (http://www.cloudscape.com), PointBase (http://www.pointbase.com), or InstantDB (http://www.lutris.com/products/instantDB). • These databases are less powerful but simple to set up. 10
  • 11. Installing JDBC… •Essentially all database vendors already have JDBC drivers. •You need to locate the vendor's instructions to load the driver into your program and to connect to the database. 11
  • 12. Basic JDBC Programming Concepts •Programming with the JDBC classes is, by design, not very different from programming with the usual Java platform classes: •You build objects from the JDBC core classes, extending them by inheritance if need be. 12
  • 13. Components of JDBC 1. The JDBC API. 2. The JDBC Driver Manager. 3. The JDBC Test Suite. 4. The JDBC-ODBC Bridge. 13
  • 14. JDBC API • The JDBC API provides the facility for accessing the relational database from the Java programming language. • The user not only execute the SQL statements, retrieve results, and update the data but can also access it anywhere within a network because of it's "Write Once, Run Anywhere" (WORA) capabilities. • Due to JDBC API technology, user can also access other tabular data sources like spreadsheets or flat files even in the a heterogeneous environment. 14
  • 15. JDBC API… • JDBC application programming interface is a part of the Java platform that have included Java SE and Java EE in itself. • The latest version of JDBC 4.0 application programming interface is divided into two packages. i) java.sql. ii) javax.sql. • Java SE and Java EE platforms are included in both the packages. 15
  • 16. JDBC Driver • A JDBC driver translates standard JDBC calls into a network or database protocol OR into a database library API call that facilitates communication with the database. • There are four distinct types of JDBC drivers. 1. JDBC-ODBC Bridge + ODBC Driver, also called as Type1 2. Native API , Pure/partly Java Driver, also called Type 2. 3. JDBC –Net Pure Java Driver, also called Type 3. 4. Native Protocol , Pure Java Driver, also called Type 4. 16
  • 17. JDBC Driver Manager • The JDBC Driver Manager is a very important class that defines objects which connect Java applications to a JDBC driver. • Usually Driver Manager is the backbone of the JDBC architecture. • It's very simple and small that is used to provide a means of managing the different types of JDBC database driver running on an application. 17
  • 18. JDBC Driver Manager… •The main responsibility of JDBC database driver is to load all the drivers found in the system properly as well as to select the most appropriate driver from opening a connection to a database. •The Driver Manager also helps to select the most appropriate driver from the previously loaded drivers when a new open database is connected. 18
  • 19. JDBC Test Suite •The function of JDBC driver test suite is to make ensure that the JDBC drivers will run user's program or not . •The test suite of JDBC application program interface is very useful for testing a driver based on JDBC technology during testing period. •It ensures the requirement of Java Platform Enterprise Edition (J2EE). 19
  • 20. ODBC (Open Data Base Connectivity) •Open DataBase Connectivity is similar to Java Database Connectivity which is used for accessing and managing database, but the difference is that JDBC is designed specifically for Java programs, whereas ODBC is not depended upon any language. 20
  • 21. JDBC-ODBC Bridge •The JDBC-ODBC bridge, also known as JDBC type 1 driver is a database driver that utilize the ODBC driver to connect the database. •This driver translates JDBC method calls into ODBC function calls. •The Bridge implements Jdbc for any database for which an Odbc driver is available. •The Bridge is always implemented as the sun.jdbc.odbc Java package and it contains a 21
  • 22. Functions of JDBC-ODBC Bridge •Translates query obtained by JDBC into corresponding ODBC query, which is then handled by the ODBC driver. •Sun provides a JDBC-ODBC Bridge driver. sun.jdbc.odbc.JdbcOdbcDriver. This driver is native code and not Java, and is closed source. •Client -> JDBC Driver -> ODBC Driver -> Database •There is some overhead associated with the translation work to go from JDBC to ODBC. 22
  • 23. Components of JDBC •This first two component of JDBC, the JDBC API and the JDBC Driver Manager manages to connect to the database and then build a java program that utilizes SQL commands to communicate with any RDBMS. •On the other hand, the last two components are used to communicate with ODBC or to test web application in the specialized environment. 23
  • 24. References ➢S. Horstmann and Gary Cornell, Core Java 2 – Volume II- Advanced Features, Sun Microsystems Press ➢Harvey M. Deitel and Paul J. Deitel, Java How to Program, Deitel & Associates ➢Nitesh Kukreja and Pooja Talreja, “An introduction to java connectivity (JDBC),” 24 Gerabirhan Paulos [email protected]