SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

La actualidad más candente

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
 

La actualidad más candente (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
 

Similar a 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
 

Último

Último (20)

Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 

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