SlideShare une entreprise Scribd logo
1  sur  23
By
M.YAMUNA DEVI
CSE Department , 10AG1AO568
CONTENTS
Introduction.
Importance of databases.
Jdbc.
Jdbc api,architecture.
Jdbc key components with steps.
Overview of querying a db with
stages.
Advantages and disadvantages.
Conclusion.
Why Java??
>Write once, run anywhere
> Multiple client and server platforms
>

Database independence
> Java can access any database vendor

> Ease of administration
Importance of databases:
we can store our data permanently by using file concept. If we are using file
concept we have some drawbacks.
•.if we want to use file concept we need to know about IO package concept and
can store small amount of data.
•Inserting , deleting, updating in files it takes more time.
•It does not support query language
•In files we store data in the form of text or objects.
to overcome all these problems we go for database software
In database software the data will be stored permanent it supports query
language.
it takes less time for inserting ,deleting ,updating ,retrieve .
in database s/w the data will be stored in table storing in the form of rows
and columns.
some of the database software are
1)oracle
2)mysql
3)sql server
4)DB2


>
odbc is a standard or open application programming
interface (API) for accessing a database.



Handles these requests and converts it into a request
understandable by an individual database system.



Java API for connecting programs written in Java to the
data in relational databases



The standard defined by Sun Microsystems, allowing
individual providers to implement and extend the standard with
their own JDBC drivers.


>

Tasks of JDBC:
1) establishes a connection with a database
2) sends SQL statements
3) processes the results
JDBC key components:
Driver Manager , Connection , Statement , Result Set
• Driver Manager handles communication with different
drivers that conform to JDBC Driver API
• The static class Driver Manager manages the loaded
drivers and contains methods for accessing connections
to the databases JDBC Driver Manager
Four steps in creating a database
application
Step 1: load a database driver
Step 2: make a database connection
Step 3: create and execute SQL statement
Step 4: process the result set , if necessary
Step 1: Loading a Driver
•Loading a driver requires class name of the driver
•For JDBC-ODBC driver the class name is: sun. jdbc.Odbc .JdbcOdbcDriver
try {
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);
}
•The class definition of the driver is loaded using forName static method
of the class Class (in package java.lang )
• catch (Exception e)
{
System.out.println(e);
}
Step 2: Opening a Database Connection
• Connection is an interface defined in java.sql package.
A Connection object represents a connection with the
database.
The interface has methods to create statements which
can be used to manipulate the database.
Connection
cn=DriverManager.getConnection(“jdbc:odbc:ora”,”yamu
na”,”ace”);
Step 3: Creating Statement & executing SQL
Statements
Connection objects can be used to create statement
objects.
Statement = cn.createStatement();
Statement is an interface that contains methods for
executing SQL queries
Like executeUpdate()-insert,delet,update
For selection we refer executeQuery()
Step4:Retrieving the data from db
Individual column fields can be retrieved using
the get methods within the ResultSet.
String qry=“select *from employs”;
ResultSet rs=stmt.executeQuery(qry);
String id=rs.getString(1);
Resultset is the return type of executeQuery().
Columns may be specified by their field name or
by their index.
Connect

Query

Process
results

Close
Connect

Register the driver

Query

Connect to the database

Process
results

Close
Connect

Query

Create a statement

Process
results

Query the database

Close
Connect

Query
Step through the results

Process
results

Close

Assign results to Java
variables
Connect

Query
Close the result set
Process
results

Close the statement

Close

Close the connection
Advantages
1) Can read any database if proper drivers are installed.
2) Query and Stored procedure supported.

Disadvantages
1) Correct drivers need to be deployed for each type
of database
2) Cannot update or insert multiple tables with
sequence. ( Sequence is always random)
Conclusion
JDBC provides API or Protocol to interact with different databases.
With the help of JDBC driver we can connect with different types of
databases
This technology is an API for the java programming language that defines
how a client may access a database. It provides methods for querying
and updating data in a database. JDBC is oriented towards relational
databases. A JDBC-to-ODBC bridge enables connections to any ODBCaccessible data source in the JVM host environment.
References
http://www.oracle.com/technetork/java/javase/jdbc/index.h
tml.
http://docs.oracle.com/javase/tutorial/jdbc/
http://www.webopedia.com/TERM/J/JDBC.html
http://infolab.stanford.edu/~ullman/fcdb/oracle/orjdbc.html
Thank You !!!
ANY QUERIES?

Contenu connexe

Tendances

Tendances (20)

JDBC – Java Database Connectivity
JDBC – Java Database ConnectivityJDBC – Java Database Connectivity
JDBC – Java Database Connectivity
 
Net framework
Net frameworkNet framework
Net framework
 
Collections in Java Notes
Collections in Java NotesCollections in Java Notes
Collections in Java Notes
 
ADO.NET
ADO.NETADO.NET
ADO.NET
 
JDBC ppt
JDBC pptJDBC ppt
JDBC ppt
 
Java database connectivity with MySql
Java database connectivity with MySqlJava database connectivity with MySql
Java database connectivity with MySql
 
5 collection framework
5 collection framework5 collection framework
5 collection framework
 
Java I/o streams
Java I/o streamsJava I/o streams
Java I/o streams
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
 
JPA For Beginner's
JPA For Beginner'sJPA For Beginner's
JPA For Beginner's
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Linq
LinqLinq
Linq
 
Dom(document object model)
Dom(document object model)Dom(document object model)
Dom(document object model)
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in java
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
ReactJS presentation.pptx
ReactJS presentation.pptxReactJS presentation.pptx
ReactJS presentation.pptx
 
ORACLE PL SQL
ORACLE PL SQLORACLE PL SQL
ORACLE PL SQL
 
Strings in Java
Strings in Java Strings in Java
Strings in Java
 
Collections and its types in C# (with examples)
Collections and its types in C# (with examples)Collections and its types in C# (with examples)
Collections and its types in C# (with examples)
 
Spring framework in depth
Spring framework in depthSpring framework in depth
Spring framework in depth
 

Similaire à Jdbc

Similaire à Jdbc (20)

Unit 5.pdf
Unit 5.pdfUnit 5.pdf
Unit 5.pdf
 
Jdbc
JdbcJdbc
Jdbc
 
Jdbc connectivity
Jdbc connectivityJdbc connectivity
Jdbc connectivity
 
Java- JDBC- Mazenet Solution
Java- JDBC- Mazenet SolutionJava- JDBC- Mazenet Solution
Java- JDBC- Mazenet Solution
 
JDBC.ppt
JDBC.pptJDBC.ppt
JDBC.ppt
 
JDBC
JDBCJDBC
JDBC
 
Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)
 
java 4 Part 1 computer science.pptx
java 4 Part 1 computer science.pptxjava 4 Part 1 computer science.pptx
java 4 Part 1 computer science.pptx
 
Jdbc complete
Jdbc completeJdbc complete
Jdbc complete
 
Module4_Annotations_JDBC.pdf
Module4_Annotations_JDBC.pdfModule4_Annotations_JDBC.pdf
Module4_Annotations_JDBC.pdf
 
Core jdbc basics
Core jdbc basicsCore jdbc basics
Core jdbc basics
 
Chap3 3 12
Chap3 3 12Chap3 3 12
Chap3 3 12
 
Java Database Connectivity
Java Database ConnectivityJava Database Connectivity
Java Database Connectivity
 
java.pptx
java.pptxjava.pptx
java.pptx
 
Jdbc
JdbcJdbc
Jdbc
 
Java database connectivity
Java database connectivityJava database connectivity
Java database connectivity
 
Java database connectivity
Java database connectivityJava database connectivity
Java database connectivity
 
Java Data Base Connectivity concepts.pptx
Java Data Base Connectivity concepts.pptxJava Data Base Connectivity concepts.pptx
Java Data Base Connectivity concepts.pptx
 
Jdbc introduction
Jdbc introductionJdbc introduction
Jdbc introduction
 
4-INTERDUCATION TO JDBC-2019.ppt
4-INTERDUCATION TO JDBC-2019.ppt4-INTERDUCATION TO JDBC-2019.ppt
4-INTERDUCATION TO JDBC-2019.ppt
 

Dernier

Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAnitaRaj43
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 

Dernier (20)

Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 

Jdbc

  • 2. CONTENTS Introduction. Importance of databases. Jdbc. Jdbc api,architecture. Jdbc key components with steps. Overview of querying a db with stages. Advantages and disadvantages. Conclusion.
  • 3. Why Java?? >Write once, run anywhere > Multiple client and server platforms > Database independence > Java can access any database vendor > Ease of administration
  • 4. Importance of databases: we can store our data permanently by using file concept. If we are using file concept we have some drawbacks. •.if we want to use file concept we need to know about IO package concept and can store small amount of data. •Inserting , deleting, updating in files it takes more time. •It does not support query language •In files we store data in the form of text or objects. to overcome all these problems we go for database software
  • 5. In database software the data will be stored permanent it supports query language. it takes less time for inserting ,deleting ,updating ,retrieve . in database s/w the data will be stored in table storing in the form of rows and columns. some of the database software are 1)oracle 2)mysql 3)sql server 4)DB2
  • 6.  > odbc is a standard or open application programming interface (API) for accessing a database.  Handles these requests and converts it into a request understandable by an individual database system.  Java API for connecting programs written in Java to the data in relational databases  The standard defined by Sun Microsystems, allowing individual providers to implement and extend the standard with their own JDBC drivers. 
  • 7. > Tasks of JDBC: 1) establishes a connection with a database 2) sends SQL statements 3) processes the results
  • 8. JDBC key components: Driver Manager , Connection , Statement , Result Set • Driver Manager handles communication with different drivers that conform to JDBC Driver API • The static class Driver Manager manages the loaded drivers and contains methods for accessing connections to the databases JDBC Driver Manager
  • 9. Four steps in creating a database application Step 1: load a database driver Step 2: make a database connection Step 3: create and execute SQL statement Step 4: process the result set , if necessary
  • 10. Step 1: Loading a Driver •Loading a driver requires class name of the driver •For JDBC-ODBC driver the class name is: sun. jdbc.Odbc .JdbcOdbcDriver try { Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”); } •The class definition of the driver is loaded using forName static method of the class Class (in package java.lang ) • catch (Exception e) { System.out.println(e); }
  • 11. Step 2: Opening a Database Connection • Connection is an interface defined in java.sql package. A Connection object represents a connection with the database. The interface has methods to create statements which can be used to manipulate the database. Connection cn=DriverManager.getConnection(“jdbc:odbc:ora”,”yamu na”,”ace”);
  • 12. Step 3: Creating Statement & executing SQL Statements Connection objects can be used to create statement objects. Statement = cn.createStatement(); Statement is an interface that contains methods for executing SQL queries Like executeUpdate()-insert,delet,update For selection we refer executeQuery()
  • 13. Step4:Retrieving the data from db Individual column fields can be retrieved using the get methods within the ResultSet. String qry=“select *from employs”; ResultSet rs=stmt.executeQuery(qry); String id=rs.getString(1); Resultset is the return type of executeQuery(). Columns may be specified by their field name or by their index.
  • 15. Connect Register the driver Query Connect to the database Process results Close
  • 17. Connect Query Step through the results Process results Close Assign results to Java variables
  • 18. Connect Query Close the result set Process results Close the statement Close Close the connection
  • 19. Advantages 1) Can read any database if proper drivers are installed. 2) Query and Stored procedure supported. Disadvantages 1) Correct drivers need to be deployed for each type of database 2) Cannot update or insert multiple tables with sequence. ( Sequence is always random)
  • 20. Conclusion JDBC provides API or Protocol to interact with different databases. With the help of JDBC driver we can connect with different types of databases This technology is an API for the java programming language that defines how a client may access a database. It provides methods for querying and updating data in a database. JDBC is oriented towards relational databases. A JDBC-to-ODBC bridge enables connections to any ODBCaccessible data source in the JVM host environment.