SlideShare une entreprise Scribd logo
1  sur  15
A presentation about Java Database
Connectivity
Name: Md. Easin Arafat Chowdhury
Department: CSE
Student Id: 162015040
Green University of Bangladesh
Name: Md. Easin Arafat Chowdhury
Department: CSE
Student Id: 162015040
Green University of Bangladesh
Overview of JDBC
Java Database Connectivity (JDBC) is an application
programming interface (API) for the programming
language Java, which defines how a client may access a
database. It is part of the Java Standard Edition
platform, from Oracle Corporation. It provides methods
to query and update data in a database, and is oriented
towards relational databases.
2
Architecture of JDBC
3
Types of JDBC drivers
• Type-1: jdbc-odbc bridge drivers.
• Type-2: native API partly java driver.
• Type-3: net protocols all java drivers.
• Type-4: native protocols all java drivers.
4
Steps to Connect ?
• Define the connection URL.
• Established the connection.
• Create the statement object.
• Execute a query.
• Process the results.
• Close the connection.
5
Steps to Connect ?
• Define the connection URL :
Class.for Name();
• For jdbc-odbc bridge driver:-
Class.for Name(“ sun.jdbc.odbc.JdbcOdbcDriver”);
• For Oracle driver:-
Class.for Name(“oracle.jdbc.driver.OracleDriver”);
• For My SQL driver:-
Class.for Name(“com.mysql.jdbcDriver”);
6
Steps to Connect ?
• Established the connection:
Connection con
= DriverManager.getConnection(“ url”, “user_name”,
“pass”)
• Create the statement object:
Statement stmt = con.createStatement();
7
Steps to Connect ?
• Execute the query:-
For the SELECT query-
String sql = “ SELECT * FROM EMP”;
Stmt.executeQuery(sql);
For the INSERT and UPDATE query-
String sql = “INSERT INTO EMP VALUES(47, “
TEDDY”)”;
Stmt.executeUpdate(sql);
8
Steps to Connect ?
• Close the connection and release all the resources that
the connection is holding.
Stmt.close();
Con.close();
9
Types of Statement available
• There are three types of statement are available in statement
class:-
Statement
Prepared Statement
Callable Statement
10
JDBC Data Source
• The JDBS data source interface is an alternative to
DriverManager class and conventional JDBC url. All the
database information is present in the naming service and
retrieved using the JNDI API. The Data Source object
contrains the connection information which will make the
actual connection and execute the JDBC commands.
11
JDBC Data Source
• Each Data Source is assigned a logical name by
conventional beginning with jdbc /.
• Advantage :-
Make the code portable and reuse.
The application does not have to remember the hardcore
driver information.
Connection pooling and distributed transaction
advantages is facilitate.
12
JDBC Data Source
• Syntax:-
Context ctx = new initial Context();
Data Source:-
ds = (Data Source)ctx.lookup(“ jdbc/teddyDB”);
Connection:-
Con = ds.getConnection(“ user_name”, “pass”);
13
14
15

Contenu connexe

Tendances

Jdbc (database in java)
Jdbc (database in java)Jdbc (database in java)
Jdbc (database in java)
Maher Abdo
 
Jdbc slide for beginers
Jdbc slide for beginersJdbc slide for beginers
Jdbc slide for beginers
Ambarish Rai
 
Java Database Connectivity
Java Database ConnectivityJava Database Connectivity
Java Database Connectivity
backdoor
 

Tendances (20)

Jdbc
JdbcJdbc
Jdbc
 
Jdbc
JdbcJdbc
Jdbc
 
Java database connectivity
Java database connectivityJava database connectivity
Java database connectivity
 
JDBC
JDBCJDBC
JDBC
 
Jdbc
JdbcJdbc
Jdbc
 
Jdbc (database in java)
Jdbc (database in java)Jdbc (database in java)
Jdbc (database in java)
 
Java database connectivity with MySql
Java database connectivity with MySqlJava database connectivity with MySql
Java database connectivity with MySql
 
Ajp notes-chapter-05
Ajp notes-chapter-05Ajp notes-chapter-05
Ajp notes-chapter-05
 
1. java database connectivity (jdbc)
1. java database connectivity (jdbc)1. java database connectivity (jdbc)
1. java database connectivity (jdbc)
 
java Jdbc
java Jdbc java Jdbc
java Jdbc
 
Java- JDBC- Mazenet Solution
Java- JDBC- Mazenet SolutionJava- JDBC- Mazenet Solution
Java- JDBC- Mazenet Solution
 
Jdbc
JdbcJdbc
Jdbc
 
Jdbc slide for beginers
Jdbc slide for beginersJdbc slide for beginers
Jdbc slide for beginers
 
Jdbc
JdbcJdbc
Jdbc
 
Java Database Connectivity
Java Database ConnectivityJava Database Connectivity
Java Database Connectivity
 
JDBC Connectivity Model
JDBC Connectivity ModelJDBC Connectivity Model
JDBC Connectivity Model
 
Overview Of JDBC
Overview Of JDBCOverview Of JDBC
Overview Of JDBC
 
Database Access With JDBC
Database Access With JDBCDatabase Access With JDBC
Database Access With JDBC
 
JDBC Tutorial
JDBC TutorialJDBC Tutorial
JDBC Tutorial
 
Jdbc complete
Jdbc completeJdbc complete
Jdbc complete
 

Similaire à Jdbc (20)

Jdbc
JdbcJdbc
Jdbc
 
jdbc
jdbcjdbc
jdbc
 
10 J D B C
10  J D B C10  J D B C
10 J D B C
 
Chap3 3 12
Chap3 3 12Chap3 3 12
Chap3 3 12
 
Jdbc
JdbcJdbc
Jdbc
 
chapter 5 java.pptx
chapter 5  java.pptxchapter 5  java.pptx
chapter 5 java.pptx
 
JDBC with MySQL.pdf
JDBC with MySQL.pdfJDBC with MySQL.pdf
JDBC with MySQL.pdf
 
JDBC with MySQL.pdf
JDBC with MySQL.pdfJDBC with MySQL.pdf
JDBC with MySQL.pdf
 
Java database connectivity with MySql
Java database connectivity with MySqlJava database connectivity with MySql
Java database connectivity with MySql
 
java database connectivity for java programming
java database connectivity for java programmingjava database connectivity for java programming
java database connectivity for java programming
 
4-INTERDUCATION TO JDBC-2019.ppt
4-INTERDUCATION TO JDBC-2019.ppt4-INTERDUCATION TO JDBC-2019.ppt
4-INTERDUCATION TO JDBC-2019.ppt
 
Basic Java Database Connectivity(JDBC)
Basic Java Database Connectivity(JDBC)Basic Java Database Connectivity(JDBC)
Basic Java Database Connectivity(JDBC)
 
Jdbc new
Jdbc newJdbc new
Jdbc new
 
Jdbc
Jdbc   Jdbc
Jdbc
 
Jdbc
JdbcJdbc
Jdbc
 
JDBC.ppt
JDBC.pptJDBC.ppt
JDBC.ppt
 
Unit 5.pdf
Unit 5.pdfUnit 5.pdf
Unit 5.pdf
 
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
 
Java database connectivity
Java database connectivityJava database connectivity
Java database connectivity
 
JDBC
JDBCJDBC
JDBC
 

Dernier

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
SoniaTolstoy
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Krashi Coaching
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
fonyou31
 

Dernier (20)

Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 

Jdbc

  • 1. A presentation about Java Database Connectivity Name: Md. Easin Arafat Chowdhury Department: CSE Student Id: 162015040 Green University of Bangladesh Name: Md. Easin Arafat Chowdhury Department: CSE Student Id: 162015040 Green University of Bangladesh
  • 2. Overview of JDBC Java Database Connectivity (JDBC) is an application programming interface (API) for the programming language Java, which defines how a client may access a database. It is part of the Java Standard Edition platform, from Oracle Corporation. It provides methods to query and update data in a database, and is oriented towards relational databases. 2
  • 4. Types of JDBC drivers • Type-1: jdbc-odbc bridge drivers. • Type-2: native API partly java driver. • Type-3: net protocols all java drivers. • Type-4: native protocols all java drivers. 4
  • 5. Steps to Connect ? • Define the connection URL. • Established the connection. • Create the statement object. • Execute a query. • Process the results. • Close the connection. 5
  • 6. Steps to Connect ? • Define the connection URL : Class.for Name(); • For jdbc-odbc bridge driver:- Class.for Name(“ sun.jdbc.odbc.JdbcOdbcDriver”); • For Oracle driver:- Class.for Name(“oracle.jdbc.driver.OracleDriver”); • For My SQL driver:- Class.for Name(“com.mysql.jdbcDriver”); 6
  • 7. Steps to Connect ? • Established the connection: Connection con = DriverManager.getConnection(“ url”, “user_name”, “pass”) • Create the statement object: Statement stmt = con.createStatement(); 7
  • 8. Steps to Connect ? • Execute the query:- For the SELECT query- String sql = “ SELECT * FROM EMP”; Stmt.executeQuery(sql); For the INSERT and UPDATE query- String sql = “INSERT INTO EMP VALUES(47, “ TEDDY”)”; Stmt.executeUpdate(sql); 8
  • 9. Steps to Connect ? • Close the connection and release all the resources that the connection is holding. Stmt.close(); Con.close(); 9
  • 10. Types of Statement available • There are three types of statement are available in statement class:- Statement Prepared Statement Callable Statement 10
  • 11. JDBC Data Source • The JDBS data source interface is an alternative to DriverManager class and conventional JDBC url. All the database information is present in the naming service and retrieved using the JNDI API. The Data Source object contrains the connection information which will make the actual connection and execute the JDBC commands. 11
  • 12. JDBC Data Source • Each Data Source is assigned a logical name by conventional beginning with jdbc /. • Advantage :- Make the code portable and reuse. The application does not have to remember the hardcore driver information. Connection pooling and distributed transaction advantages is facilitate. 12
  • 13. JDBC Data Source • Syntax:- Context ctx = new initial Context(); Data Source:- ds = (Data Source)ctx.lookup(“ jdbc/teddyDB”); Connection:- Con = ds.getConnection(“ user_name”, “pass”); 13
  • 14. 14
  • 15. 15