SlideShare a Scribd company logo
IADCS Diploma Course Java Database Connectivity U Nyein Oo COO/Director (IT) Myanma Computer Co., Ltd
JDBC API   JDBC API stands for Java Database Connectivity Application Programming Interface   It is a set of specifications that defines how a Java program can communicate with the database   It defines how an application opens a connection, communicates with the database, executes SQL statements and retrieves the results Many of the JDBC API concepts are taken from other sources, particularly Microsoft’s ODBC (Open Database Connectivity)
JDBC API (Contd…) Figure below depicts the functioning of the JDBC API
JDBC Drivers   It ensures that the application interacts with all databases in a standard and uniform manner   It ensures that the requests made by the application are presented to the database in a language understood by the database   It receives the requests from the client, converts it into the format understandable by the database and then presents it to the database   It receives the response, translates it back to Java data format and presents it to the client application   All databases follow SQL and hence there is only one JDBC Driver, that is, the Java-to-SQL translator
JDBC Drivers (Contd…) Figure below depicts the working of JDBC Driver
JDBC Products   Three components of JDBC:   java.sql package Test Suite JDBC-ODBC bridge
java.sql  package It contains a set of interfaces and classes defined by JDBC API that are used for communicating with the database   Interfaces of  java.sql  package: CallableStatement   Connection   DatabaseMetaData   Driver PreparedStatement   ResultSet   ResultSetMetaData   Statement
java.sql  package (Contd…) Exceptions defined by  java.sql  package: DataTruncation SQLException SQLWarning
JDBC Driver Test Suite   It tests the functionality of a JDBC Driver   It ensures that all classes and methods defined in the JDBC API are implemented   Once the driver passes through all the tests, the test suite can be designated as JDBC COMPLAINT
JDBC-ODBC Bridge   It is a JDBC driver designed to allow Java applications to communicate with the database using ODBC driver   It allows developers to begin writing JDBC applications without having to wait for a native driver for their database   It is a part of the JDBC package
JDBC Products (Contd…) To work with JDBC API the following are required: Java Development ToolKit (JDK)   SQL complaint database JDBC driver for database
JDBC Design Considerations   JDBC driver fits into the architecture of various client/server models  Four types of JDBC drivers: JDBC-ODBC Bridge   Native API Java   JDBC Network   Native Protocol
JDBC-ODBC Bridge   This driver is supplied by JavaSoft.   It is the only driver that can be used with multiple databases.   The ODBC interface remains constant no matter which database is used. Once the request is passed by the JDBC to the ODBC driver, it is the responsibility of the ODBC driver to communicate it with the database.   An disadvantage of JDBC-ODBC bridge driver is that it adds one more layer of complexity to the program and can make software bugs more difficult  to solve.
JDBC-ODBC Bridge (Contd...) Figure below depicts how JDBC-ODBC bridge driver is implemented
Native-API-Partly-Java Driver   It makes use of local native libraries to communicate with the database   It does this by calling to the local installed native call level interface (CLI)   The CLI libraries are actually responsible for the communication with the database server   When a client makes a request, the driver translates the JDBC request to the native method call and then passes the request to the native CLI
Native-API-Partly-Java Driver (Contd...) Figure below depicts how native driver is implemented
JDBC-Net-All-Java Driver   The only difference between the previous two drivers is the placement of the native database access libraries   The native CLI libraries are placed on the remote server and the driver uses a network protocol to communicate between the application and the driver   The driver is split into two parts: one containing all Java portion that can be downloaded to the client and the server portion containing both Java and native methods
Native-Protocol-All-Java Driver   These drivers are 100% Java and use no CLI libraries  It is capable of communicating directly with the database without any need of translation
Two-Tier Client Server Model   The architecture of any client-server environment is by default a two-tier system   The client is the first tier and the server the second tier   In a two-tier JDBC environment, the database application is the client and the DBMS is the server The client communicates directly with the server
Two-Tier Client Server Model  (Contd...) Figure below depicts a two-tier client-server model
Advantages of using a two-tier database system:   It is the least complicated system to implement   This architecture maintains a constant connection between the client and the database   This system is usually faster than a three-tier implementation   Disadvantages of using this system:  Most of the drivers require that native libraries be loaded on the client machine   Local configuration has to be maintained for native code   Applets can open up connection to the server from which they are downloaded   Two-Tier Client Server Model  (Contd...)
Three-Tier Client Server Model   In this system, a third server is employed to handle requests from the client and then pass them to the database server   This third server acts as a proxy for all client requests   This model has the advantage of allowing separation of the database server from the web server   In such an environment, the driver translates the request into a network protocol and then requests via the proxy server
Three-Tier Client Server Model (Contd...) Figure below depicts a three-tier client-server environment
Basic Steps to JDBC   Seven steps in using JDBC to access a database:   Importing java.sql package   Loading and registering the driver   Establishing a connection to the database server   Creating a statement   Executing the statement   Retrieving the results   Closing the statement and connection
Basic Steps to JDBC ( contd.. ) Figure below depicts the steps
Setting up a Connection to the Database   java.sql  package provides database programming capabilities to Java   JDBC API is a programming interface for application developers doing development through database   Another major component of JDBC is the JDBC Driver API   A database server and database driver  are required f or using JDBC
Setting up a Connection to the Database (Contd...) java.sql.DriverManager  class provides methods to load drivers. It consists of the following methods:  getDrivers( )   getConnection( )   registerDriver( )   deregisterDriver( )   getLoginTimeout( )  setLoginTimeout( )   getLogStream( )  setLogStream( )
Creating and Executing SQL Statements   An SQL statement is at the center of any JDBC  The SQL statement and the JDBC representation are the same   The JDBC string needs to be modified to ensure that the database receives the intended SQL statement   Any string that is identical to the SQL statement is referred to as simple SQL Statement and those requiring some modifications are considered complex   Queries are one of the most important forms of SQL statements
Creating and Executing SQL Statements (Contd…)  In JDBC, all queries return results in the form of  ResultSet  objects   The most efficient way to execute a query is to use the  Statement.executeQuery( )  method   Time and Date Literals   handling is also possible in JDBC Outer joins are also supported by JDBC
ResultSet and  ResultSetMetaData Objects   The result of the query is returned in the form of rows and columns   The  ResultSet interface  is used to access this data The query results are returned as  ResultSet   objects  that in turn provide access to the tabular data, one row at a time   ResultSetMetaData interface  provides constants and methods used to obtain information about the ResultSet   object
Stored Procedures   A stored procedure is a group of SQL statements that form a logical unit and perform a particular task   They are used to encapsulate a set of operations or queries to execute on a database server   They can be compiled and executed with different parameters and results They are supported by most DBMSs, but there is a fair amount of variation in their syntax and capabilities
Stored Procedures (Contd…) Syntax for creating a procedure   create procedure <proc_name> as select <column_name/s> from <table name/s> where <query>
Calling Stored Procedures  Syntax for calling a stored procedure CallableStatement cs = con.prepareCall(&quot;{call <Proc_name>}&quot;); ResultSet rs = cs.executeQuery(); Note that the method used to execute ‘cs’ is  executeQuery( )  because ‘cs’ calls a stored procedure that contains one query and thus produces one result set   If the procedure had contained one update or one DDL statement, the method  executeUpdate( )  would have been the one to use
Database Security   Database security is of vital importance.   The data contains sensitive and confidential information about the company and hence vital care has to be taken to see that no unauthorized users access it and thereby tamper with the data.   Data availability is also of utmost importance.   It should be available whenever required. JDBC depends on the database server for providing security.
Database Security (Contd…) The JDBC makes use of Secure Socket Layer (SSL) in their product lines  t hat provides encrypted communication between database driver and server

More Related Content

What's hot (20)

JDBC
JDBCJDBC
JDBC
People Strategists
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
shreesenthil
 
SQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics CoveredSQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics Covered
Danish Mehraj
 
ASP.NET Page Life Cycle
ASP.NET Page Life CycleASP.NET Page Life Cycle
ASP.NET Page Life Cycle
Abhishek Sur
 
Spring Boot
Spring BootSpring Boot
Spring Boot
HongSeong Jeon
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
tola99
 
Hibernate in Action
Hibernate in ActionHibernate in Action
Hibernate in Action
Akshay Ballarpure
 
Abstract class in java
Abstract class in javaAbstract class in java
Abstract class in java
Lovely Professional University
 
Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state management
priya Nithya
 
MySQL Performance Schema in MySQL 8.0
MySQL Performance Schema in MySQL 8.0MySQL Performance Schema in MySQL 8.0
MySQL Performance Schema in MySQL 8.0
Mayank Prasad
 
SQL Queries
SQL QueriesSQL Queries
SQL Queries
Nilt1234
 
Cookies and sessions
Cookies and sessionsCookies and sessions
Cookies and sessions
Lena Petsenchuk
 
C# Exceptions Handling
C# Exceptions Handling C# Exceptions Handling
C# Exceptions Handling
sharqiyem
 
Javascript essentials
Javascript essentialsJavascript essentials
Javascript essentials
Bedis ElAchèche
 
Javascript
JavascriptJavascript
Javascript
Rajavel Dhandabani
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
Hitesh Kumar
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
Amit Tyagi
 
HTML5: features with examples
HTML5: features with examplesHTML5: features with examples
HTML5: features with examples
Alfredo Torre
 
JDBC – Java Database Connectivity
JDBC – Java Database ConnectivityJDBC – Java Database Connectivity
JDBC – Java Database Connectivity
Information Technology
 
MYSQL - PHP Database Connectivity
MYSQL - PHP Database ConnectivityMYSQL - PHP Database Connectivity
MYSQL - PHP Database Connectivity
V.V.Vanniaperumal College for Women
 

Viewers also liked (20)

JDBC Java Database Connectivity
JDBC Java Database ConnectivityJDBC Java Database Connectivity
JDBC Java Database Connectivity
Ranjan Kumar
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
Tanmoy Barman
 
How to Backdoor Diffie-Hellman
How to Backdoor Diffie-HellmanHow to Backdoor Diffie-Hellman
How to Backdoor Diffie-Hellman
David Wong
 
BackDoors Seminar
BackDoors SeminarBackDoors Seminar
BackDoors Seminar
Chaitali Patel
 
Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
Vikas Jagtap
 
Trojans and backdoors
Trojans and backdoorsTrojans and backdoors
Trojans and backdoors
Gaurav Dalvi
 
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
 
Jdbc Ppt
Jdbc PptJdbc Ppt
Jdbc Ppt
Centre for Budget and Governance Accountability (CBGA)
 
Penetración con una Backdoor
Penetración con una BackdoorPenetración con una Backdoor
Penetración con una Backdoor
NEGOCIOS PROPIOS
 
Backdoor
BackdoorBackdoor
Backdoor
phanleson
 
Finding the back door to people’s hearts
Finding the back door to people’s heartsFinding the back door to people’s hearts
Finding the back door to people’s hearts
Third Column Ministries
 
Expert System MYCIN
Expert System MYCINExpert System MYCIN
Expert System MYCIN
Rached Krim
 
JDBC Basics (In 20 Minutes Flat)
JDBC Basics (In 20 Minutes Flat)JDBC Basics (In 20 Minutes Flat)
JDBC Basics (In 20 Minutes Flat)
Craig Dickson
 
Trojan virus & backdoors
Trojan virus & backdoorsTrojan virus & backdoors
Trojan virus & backdoors
Shrey Vyas
 
SOAR!!!
SOAR!!!SOAR!!!
SOAR!!!
roopakdesai
 
Olms ppt
Olms pptOlms ppt
Olms ppt
saritabhateja
 
.NET Code Examples
.NET Code Examples.NET Code Examples
.NET Code Examples
GaryB47
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfolio
CRD Alternatives, Inc.
 
Framework Project
Framework  ProjectFramework  Project
Framework Project
Mauro_Sist
 
Java Intro
Java IntroJava Intro
Java Intro
backdoor
 
Ad

Similar to Java Database Connectivity (20)

Java Database Connectivity by shreyash simu dbce.pptx
Java Database Connectivity by shreyash simu dbce.pptxJava Database Connectivity by shreyash simu dbce.pptx
Java Database Connectivity by shreyash simu dbce.pptx
ash909077
 
Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)
Pooja Talreja
 
Rajesh jdbc
Rajesh   jdbcRajesh   jdbc
Rajesh jdbc
Aditya Sharma
 
Jdbc 1
Jdbc 1Jdbc 1
Jdbc 1
Mukesh Tekwani
 
java.pptx
java.pptxjava.pptx
java.pptx
bfgd1
 
Core jdbc basics
Core jdbc basicsCore jdbc basics
Core jdbc basics
Sourabrata Mukherjee
 
Jdbc
JdbcJdbc
Jdbc
Mumbai Academisc
 
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
Jdbc
Mumbai Academisc
 
JDBC Presentation with JAVA code Examples.pdf
JDBC Presentation with JAVA code Examples.pdfJDBC Presentation with JAVA code Examples.pdf
JDBC Presentation with JAVA code Examples.pdf
ssuser8878c1
 
Unit 5.pdf
Unit 5.pdfUnit 5.pdf
Unit 5.pdf
saturo3011
 
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 introduction
Jdbc introductionJdbc introduction
Jdbc introduction
Rakesh Kumar Ray
 
jdbc
jdbcjdbc
jdbc
Gayatri Patel
 
JDBC-Introduction
JDBC-IntroductionJDBC-Introduction
JDBC-Introduction
Mythili Shankar
 
jdbc document
jdbc documentjdbc document
jdbc document
Yamuna Devi
 
Java and Database - Interacting with database
Java and Database - Interacting with databaseJava and Database - Interacting with database
Java and Database - Interacting with database
Amol Gaikwad
 
Jdbc 1
Jdbc 1Jdbc 1
Jdbc 1
Tuan Ngo
 
What is JDBC
What is JDBCWhat is JDBC
What is JDBC
university of education,Lahore
 
Java database connectivity
Java database connectivityJava database connectivity
Java database connectivity
Vaishali Modi
 
Ad

More from backdoor (20)

Distributed Programming using RMI
 Distributed Programming using RMI Distributed Programming using RMI
Distributed Programming using RMI
backdoor
 
Programming Server side with Sevlet
 Programming Server side with Sevlet  Programming Server side with Sevlet
Programming Server side with Sevlet
backdoor
 
Distributed Programming using RMI
Distributed Programming using RMIDistributed Programming using RMI
Distributed Programming using RMI
backdoor
 
Client Side Programming with Applet
Client Side Programming with AppletClient Side Programming with Applet
Client Side Programming with Applet
backdoor
 
Java Network Programming
Java Network ProgrammingJava Network Programming
Java Network Programming
backdoor
 
Windows Programming with Swing
Windows Programming with SwingWindows Programming with Swing
Windows Programming with Swing
backdoor
 
Windows Programming with AWT
Windows Programming with AWTWindows Programming with AWT
Windows Programming with AWT
backdoor
 
Multithreading
MultithreadingMultithreading
Multithreading
backdoor
 
Object and Classes in Java
Object and Classes in JavaObject and Classes in Java
Object and Classes in Java
backdoor
 
IO and serialization
IO and serializationIO and serialization
IO and serialization
backdoor
 
Exception Handling
Exception HandlingException Handling
Exception Handling
backdoor
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
backdoor
 
AWT Program output
AWT Program outputAWT Program output
AWT Program output
backdoor
 
Net Man
Net ManNet Man
Net Man
backdoor
 
Data Security
Data SecurityData Security
Data Security
backdoor
 
Ne Course Part One
Ne Course Part OneNe Course Part One
Ne Course Part One
backdoor
 
Ne Course Part Two
Ne Course Part TwoNe Course Part Two
Ne Course Part Two
backdoor
 
Net Sec
Net SecNet Sec
Net Sec
backdoor
 
Security Policy Checklist
Security Policy ChecklistSecurity Policy Checklist
Security Policy Checklist
backdoor
 
Bcis Csm Chapter Three
Bcis Csm Chapter ThreeBcis Csm Chapter Three
Bcis Csm Chapter Three
backdoor
 
Distributed Programming using RMI
 Distributed Programming using RMI Distributed Programming using RMI
Distributed Programming using RMI
backdoor
 
Programming Server side with Sevlet
 Programming Server side with Sevlet  Programming Server side with Sevlet
Programming Server side with Sevlet
backdoor
 
Distributed Programming using RMI
Distributed Programming using RMIDistributed Programming using RMI
Distributed Programming using RMI
backdoor
 
Client Side Programming with Applet
Client Side Programming with AppletClient Side Programming with Applet
Client Side Programming with Applet
backdoor
 
Java Network Programming
Java Network ProgrammingJava Network Programming
Java Network Programming
backdoor
 
Windows Programming with Swing
Windows Programming with SwingWindows Programming with Swing
Windows Programming with Swing
backdoor
 
Windows Programming with AWT
Windows Programming with AWTWindows Programming with AWT
Windows Programming with AWT
backdoor
 
Multithreading
MultithreadingMultithreading
Multithreading
backdoor
 
Object and Classes in Java
Object and Classes in JavaObject and Classes in Java
Object and Classes in Java
backdoor
 
IO and serialization
IO and serializationIO and serialization
IO and serialization
backdoor
 
Exception Handling
Exception HandlingException Handling
Exception Handling
backdoor
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
backdoor
 
AWT Program output
AWT Program outputAWT Program output
AWT Program output
backdoor
 
Data Security
Data SecurityData Security
Data Security
backdoor
 
Ne Course Part One
Ne Course Part OneNe Course Part One
Ne Course Part One
backdoor
 
Ne Course Part Two
Ne Course Part TwoNe Course Part Two
Ne Course Part Two
backdoor
 
Security Policy Checklist
Security Policy ChecklistSecurity Policy Checklist
Security Policy Checklist
backdoor
 
Bcis Csm Chapter Three
Bcis Csm Chapter ThreeBcis Csm Chapter Three
Bcis Csm Chapter Three
backdoor
 

Recently uploaded (20)

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...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
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementaryMurdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI FoundationsOracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdfEdge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdfBoosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data ResilienceFloods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization ProgramOracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
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 accountYour 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
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 
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 ...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
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry ReportThe State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdfCrypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI ProfessionalOracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FMEEnabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training RoadblocksDown the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
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...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
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementaryMurdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI FoundationsOracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdfEdge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdfBoosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data ResilienceFloods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization ProgramOracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
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 accountYour 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
 
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2Agentic AI: Beyond the Buzz- LangGraph Studio V2
Agentic AI: Beyond the Buzz- LangGraph Studio V2
Shashikant Jagtap
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 
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 ...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
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry ReportThe State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdfCrypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI ProfessionalOracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FMEEnabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training RoadblocksDown the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 

Java Database Connectivity

  • 1. IADCS Diploma Course Java Database Connectivity U Nyein Oo COO/Director (IT) Myanma Computer Co., Ltd
  • 2. JDBC API JDBC API stands for Java Database Connectivity Application Programming Interface It is a set of specifications that defines how a Java program can communicate with the database It defines how an application opens a connection, communicates with the database, executes SQL statements and retrieves the results Many of the JDBC API concepts are taken from other sources, particularly Microsoft’s ODBC (Open Database Connectivity)
  • 3. JDBC API (Contd…) Figure below depicts the functioning of the JDBC API
  • 4. JDBC Drivers It ensures that the application interacts with all databases in a standard and uniform manner It ensures that the requests made by the application are presented to the database in a language understood by the database It receives the requests from the client, converts it into the format understandable by the database and then presents it to the database It receives the response, translates it back to Java data format and presents it to the client application All databases follow SQL and hence there is only one JDBC Driver, that is, the Java-to-SQL translator
  • 5. JDBC Drivers (Contd…) Figure below depicts the working of JDBC Driver
  • 6. JDBC Products Three components of JDBC: java.sql package Test Suite JDBC-ODBC bridge
  • 7. java.sql package It contains a set of interfaces and classes defined by JDBC API that are used for communicating with the database Interfaces of java.sql package: CallableStatement Connection DatabaseMetaData Driver PreparedStatement ResultSet ResultSetMetaData Statement
  • 8. java.sql package (Contd…) Exceptions defined by java.sql package: DataTruncation SQLException SQLWarning
  • 9. JDBC Driver Test Suite It tests the functionality of a JDBC Driver It ensures that all classes and methods defined in the JDBC API are implemented Once the driver passes through all the tests, the test suite can be designated as JDBC COMPLAINT
  • 10. JDBC-ODBC Bridge It is a JDBC driver designed to allow Java applications to communicate with the database using ODBC driver It allows developers to begin writing JDBC applications without having to wait for a native driver for their database It is a part of the JDBC package
  • 11. JDBC Products (Contd…) To work with JDBC API the following are required: Java Development ToolKit (JDK) SQL complaint database JDBC driver for database
  • 12. JDBC Design Considerations JDBC driver fits into the architecture of various client/server models Four types of JDBC drivers: JDBC-ODBC Bridge Native API Java JDBC Network Native Protocol
  • 13. JDBC-ODBC Bridge This driver is supplied by JavaSoft. It is the only driver that can be used with multiple databases. The ODBC interface remains constant no matter which database is used. Once the request is passed by the JDBC to the ODBC driver, it is the responsibility of the ODBC driver to communicate it with the database. An disadvantage of JDBC-ODBC bridge driver is that it adds one more layer of complexity to the program and can make software bugs more difficult to solve.
  • 14. JDBC-ODBC Bridge (Contd...) Figure below depicts how JDBC-ODBC bridge driver is implemented
  • 15. Native-API-Partly-Java Driver It makes use of local native libraries to communicate with the database It does this by calling to the local installed native call level interface (CLI) The CLI libraries are actually responsible for the communication with the database server When a client makes a request, the driver translates the JDBC request to the native method call and then passes the request to the native CLI
  • 16. Native-API-Partly-Java Driver (Contd...) Figure below depicts how native driver is implemented
  • 17. JDBC-Net-All-Java Driver The only difference between the previous two drivers is the placement of the native database access libraries The native CLI libraries are placed on the remote server and the driver uses a network protocol to communicate between the application and the driver The driver is split into two parts: one containing all Java portion that can be downloaded to the client and the server portion containing both Java and native methods
  • 18. Native-Protocol-All-Java Driver These drivers are 100% Java and use no CLI libraries It is capable of communicating directly with the database without any need of translation
  • 19. Two-Tier Client Server Model The architecture of any client-server environment is by default a two-tier system The client is the first tier and the server the second tier In a two-tier JDBC environment, the database application is the client and the DBMS is the server The client communicates directly with the server
  • 20. Two-Tier Client Server Model (Contd...) Figure below depicts a two-tier client-server model
  • 21. Advantages of using a two-tier database system: It is the least complicated system to implement This architecture maintains a constant connection between the client and the database This system is usually faster than a three-tier implementation Disadvantages of using this system: Most of the drivers require that native libraries be loaded on the client machine Local configuration has to be maintained for native code Applets can open up connection to the server from which they are downloaded Two-Tier Client Server Model (Contd...)
  • 22. Three-Tier Client Server Model In this system, a third server is employed to handle requests from the client and then pass them to the database server This third server acts as a proxy for all client requests This model has the advantage of allowing separation of the database server from the web server In such an environment, the driver translates the request into a network protocol and then requests via the proxy server
  • 23. Three-Tier Client Server Model (Contd...) Figure below depicts a three-tier client-server environment
  • 24. Basic Steps to JDBC Seven steps in using JDBC to access a database: Importing java.sql package Loading and registering the driver Establishing a connection to the database server Creating a statement Executing the statement Retrieving the results Closing the statement and connection
  • 25. Basic Steps to JDBC ( contd.. ) Figure below depicts the steps
  • 26. Setting up a Connection to the Database java.sql package provides database programming capabilities to Java JDBC API is a programming interface for application developers doing development through database Another major component of JDBC is the JDBC Driver API A database server and database driver are required f or using JDBC
  • 27. Setting up a Connection to the Database (Contd...) java.sql.DriverManager class provides methods to load drivers. It consists of the following methods: getDrivers( ) getConnection( ) registerDriver( ) deregisterDriver( ) getLoginTimeout( ) setLoginTimeout( ) getLogStream( ) setLogStream( )
  • 28. Creating and Executing SQL Statements An SQL statement is at the center of any JDBC The SQL statement and the JDBC representation are the same The JDBC string needs to be modified to ensure that the database receives the intended SQL statement Any string that is identical to the SQL statement is referred to as simple SQL Statement and those requiring some modifications are considered complex Queries are one of the most important forms of SQL statements
  • 29. Creating and Executing SQL Statements (Contd…) In JDBC, all queries return results in the form of ResultSet objects The most efficient way to execute a query is to use the Statement.executeQuery( ) method Time and Date Literals handling is also possible in JDBC Outer joins are also supported by JDBC
  • 30. ResultSet and ResultSetMetaData Objects The result of the query is returned in the form of rows and columns The ResultSet interface is used to access this data The query results are returned as ResultSet objects that in turn provide access to the tabular data, one row at a time ResultSetMetaData interface provides constants and methods used to obtain information about the ResultSet object
  • 31. Stored Procedures A stored procedure is a group of SQL statements that form a logical unit and perform a particular task They are used to encapsulate a set of operations or queries to execute on a database server They can be compiled and executed with different parameters and results They are supported by most DBMSs, but there is a fair amount of variation in their syntax and capabilities
  • 32. Stored Procedures (Contd…) Syntax for creating a procedure create procedure <proc_name> as select <column_name/s> from <table name/s> where <query>
  • 33. Calling Stored Procedures Syntax for calling a stored procedure CallableStatement cs = con.prepareCall(&quot;{call <Proc_name>}&quot;); ResultSet rs = cs.executeQuery(); Note that the method used to execute ‘cs’ is executeQuery( ) because ‘cs’ calls a stored procedure that contains one query and thus produces one result set If the procedure had contained one update or one DDL statement, the method executeUpdate( ) would have been the one to use
  • 34. Database Security Database security is of vital importance. The data contains sensitive and confidential information about the company and hence vital care has to be taken to see that no unauthorized users access it and thereby tamper with the data. Data availability is also of utmost importance. It should be available whenever required. JDBC depends on the database server for providing security.
  • 35. Database Security (Contd…) The JDBC makes use of Secure Socket Layer (SSL) in their product lines t hat provides encrypted communication between database driver and server