SlideShare a Scribd company logo
Database and
Java Database Connectivity
Gary
2013/06/13
Outline
• Database
• Distributed database
• Relational Database
• JDBC
• JDBC Implementation
• Future Work
Database
• What is database?
– A database is an organized collection of data. The
data is typically organized to model relevant
aspects of reality (for example, the availability of
rooms in hotels), in a way that supports processes
requiring this information (for example, finding a
hotel with vacancies).
Database
• Database system consists of
– User
– Data
– Hardware
• Where data resides
– Software
• Database management system(DBMS)
• Controls storage and retrieval
Database
• The advantage of database
– Reduce redundancy
– Avoid inconsistency
– Share data
– Enforce standards
– Security restrictions
– Data integrity
– Balance conflicting requirement
Database
• Non-database systems
– Each application has its own files
• Redundant
• Lack centralized control
Database
• Data independence
– Applications not dependent on how data stored or
accessed
– Applications can have different views of data
– Change storage/retrieval strategy without
changing applications
• Data dependency
– Change in storage or retrieval technique forces
program change
Database
• Database language
– Host languages
• Used to access database
• Can use high-level languages
– Java, C, C++, Visual Basic, COBOL, PL/I, Pascal
– Database sublanguage(DSL)
• Specifics of database objects and operations
• Combination of
– Data definition language(DDL)
– Data manipulation language(DML)
Database
• Embedding SQL statements in a host language
Distributed database
• A distributed database is a database in
which storage devices are not all attached to a
common processing unit such as the CPU,
controlled by a distributed database
management system. It may be stored in
multiple computers, located in the same
physical location; or may be dispersed over
a network of interconnected computers.
Distributed database
• Pros
– Local autonomy or site autonomy
• a department can control the data about them (as they are the
ones familiar with it)
– Protection of valuable data
• if there were ever a catastrophic event such as a fire, all of the
data would not be in one place, but distributed in multiple
locations
– Modularity
• systems can be modified, added and removed from the distributed
database without affecting other modules
– Continuous operation
• even if some nodes go offline (depending on design, like backup)
Distributed database
• Cons
– Complexity
– Economics
– Security
– Difficult to maintain integrity
Relational Database
• A relational database is a database that has a
collection of tables of data items, all of which
is formally described and organized according
to the relational model.
Relational Database
• Composed of tables
– Rows called records(tuples)
– Columns are fields(attributes)
• First field usually primary key
– Unique for each record
– Primary key can be more than one field
– Cannot allow null values
Relational Database
• Example
Relational Database
• Operations
– Projection
• Taking a subset of a table
– Join
• Combining tables to form a larger on
(by foreign key)
Relational Database
• Example of projection
Relational Database
• Advantages of relational database
– Tables easy to use, understand, and implement
– Projection and join operations easy to implement
– Easy to modify
– Great clarity and visibility
JDBC
• JDBC 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 ODBC-accessible data source in
the JVM host environment.
JDBC
• Architecture
JDBC
• There are four type of JDBC
– JDBC bridge
– Native-API bridge
– JDBC-Net
– Native-Protocol
JDBC
• JDBC bridge
• Ex: Microsoft Access Database
Java APP
JDBC API
JDBC-ODBC
Bridge
ODBC API
ODBC Layer
DB
JDBC
• Native-API bridge
Java APP
JDBC API
Native-API
Bridge
Native API
DB
JDBC
• JDBC-Net
Java APP
JDBC API
JDBC-Net
Middleware
or Server
DB
JDBC
• Native-Protocol
• Ex: MySQL
Java APP
JDBC API
Native-Protocol
DB
JDBC Implementation
• Establish database
JDBC Implementation
– Has classes and Interfaces for using relational
databases
– Implements interface Connection
– Manages connection between database and
program
4 import java.sql.*;
11 private Connection connection;
JDBC Implementation
– Database URL(location)
username to log in
password
– URL
• Protocol for communcation(jdbc)
• Subprotocol(odbc)
• Database name(Books)
19 String url = "jdbc:odbc:Books";
20 String username = "anonymous";
21 String password = "guest";
JDBC Implementation
– Static method forName ()
– Static method getconnection
• Attempt connection to database
• Name and password required
25 Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
27 connection = DriverManager.getConnection(
28 url, username, password );
JDBC Implementation
• Other JDBC driver usage
– MySQL
– Oracle
– Sybase
– Postgresql
JDBC Implementation
– The statement object
• Submits query to database
– Returns resultset object containing results
– Statement.executeUpdate
• Change data in database
– Statement.executeQuery
• Only query
49 Statement statement;
55 statement = connection.createStatement();
53 String query = "SELECT * FROM Authors";
50 ResultSet resultSet;
56 resultSet = statement.executeQuery( query );
JDBC Implementation
– Statement closed when done
– Unlock database
58 statement.close();
Conclusion
Future Wrok
• Servelets
– A servlet is a Java programming
language class used to extend the capabilities of
a server. Although servlets can respond to any
types of requests, they are commonly used to
extend the applications hosted by web servers, so
they can be thought of as Java Applets that run
on servers instead of in web browsers.

More Related Content

What's hot (20)

PPT
JDBC Architecture and Drivers
SimoniShah6
 
DOC
jdbc document
Yamuna Devi
 
PPT
Jdbc (database in java)
Maher Abdo
 
PPT
JDBC
Ankit Desai
 
PPT
JDBC Connectivity Model
kunj desai
 
PDF
Overview Of JDBC
Mindfire Solutions
 
PPT
Jdbc drivers
Prabhat gangwar
 
PDF
Ajp notes-chapter-05
Ankit Dubey
 
PDF
Jdbc connectivity in java
Muthukumaran Subramanian
 
PPT
Jdbc
myrajendra
 
PPT
Java database connectivity
Vaishali Modi
 
PPT
JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...
Pallepati Vasavi
 
PPT
Jdbc complete
Sandeep Rawat
 
PPT
Jdbc connectivity
arikazukito
 
PPT
Basic Java Database Connectivity(JDBC)
suraj pandey
 
PPTX
Jdbc drivers
Saurabh Bhartiya
 
PPS
Jdbc architecture and driver types ppt
kamal kotecha
 
PPTX
Java database connectivity with MySql
Dhyey Dattani
 
JDBC Architecture and Drivers
SimoniShah6
 
jdbc document
Yamuna Devi
 
Jdbc (database in java)
Maher Abdo
 
JDBC Connectivity Model
kunj desai
 
Overview Of JDBC
Mindfire Solutions
 
Jdbc drivers
Prabhat gangwar
 
Ajp notes-chapter-05
Ankit Dubey
 
Jdbc connectivity in java
Muthukumaran Subramanian
 
Java database connectivity
Vaishali Modi
 
JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...
Pallepati Vasavi
 
Jdbc complete
Sandeep Rawat
 
Jdbc connectivity
arikazukito
 
Basic Java Database Connectivity(JDBC)
suraj pandey
 
Jdbc drivers
Saurabh Bhartiya
 
Jdbc architecture and driver types ppt
kamal kotecha
 
Java database connectivity with MySql
Dhyey Dattani
 

Viewers also liked (13)

PDF
Database Architecture and Basic Concepts
Tony Wong
 
PPTX
Organizing Data in a Traditional File Environment
Albrecht Jones
 
PPT
Business intelligence databases and information management
Prof. Othman Alsalloum
 
PDF
Distributed Databases
elliando dias
 
PPTX
Role of Database Management in Information Systems
waQas ilYas
 
PPT
Application of spss usha (1)
Rajat Kumar Pandeya
 
PDF
Database system architecture
Dk Rukshan
 
PPT
Introduction To SPSS
Phi Jack
 
PPTX
Statistical Package for Social Science (SPSS)
sspink
 
PPTX
Spss
Tech_MX
 
PPT
Spss lecture notes
David mbwiga
 
PPT
Distributed Database System
Sulemang
 
Database Architecture and Basic Concepts
Tony Wong
 
Organizing Data in a Traditional File Environment
Albrecht Jones
 
Business intelligence databases and information management
Prof. Othman Alsalloum
 
Distributed Databases
elliando dias
 
Role of Database Management in Information Systems
waQas ilYas
 
Application of spss usha (1)
Rajat Kumar Pandeya
 
Database system architecture
Dk Rukshan
 
Introduction To SPSS
Phi Jack
 
Statistical Package for Social Science (SPSS)
sspink
 
Spss
Tech_MX
 
Spss lecture notes
David mbwiga
 
Distributed Database System
Sulemang
 
Ad

Similar to Database and Java Database Connectivity (20)

PDF
Java Database Connectivity (Advanced programming)
Gera Paulos
 
PPT
Chap3 3 12
Hemo Chella
 
PPTX
Rajesh jdbc
Aditya Sharma
 
PPT
JDBC.ppt
ChagantiSahith
 
PDF
JDBC-Introduction
Mythili Shankar
 
PPTX
DATABASE Lecture 1 and 2.pptx
RUBAB79
 
PPTX
DBMS basics and normalizations unit.pptx
shreyassoni7
 
PDF
unit8_jdbc.pdf mysql and java jdbc connection
Indu32
 
PPT
Jdbc
phanleson
 
PDF
jdbc
shreeuva
 
PPT
Final Database Connectivity in JAVA.ppt
TabassumMaktum
 
PPTX
Jdbc introduction
Rakesh Kumar Ray
 
PPTX
DATABASE MANAGEMENT SYSTEM-MRS. LAXMI B PANDYA FOR 25TH AUGUST,2022.pptx
Laxmi Pandya
 
PDF
Jdbc 1
Mukesh Tekwani
 
PPT
Jdbc sasidhar
Sasidhar Kothuru
 
PPTX
Java Database Connectivity (JDBC)
Pooja Talreja
 
DOCX
data base system to new data science lerne
tarunprajapati0t
 
PPTX
Advanced JAVA
Rajvi Vaghasiya
 
DOC
Java database programming with jdbc
sriram raj
 
PDF
Java and Database - Interacting with database
Amol Gaikwad
 
Java Database Connectivity (Advanced programming)
Gera Paulos
 
Chap3 3 12
Hemo Chella
 
Rajesh jdbc
Aditya Sharma
 
JDBC.ppt
ChagantiSahith
 
JDBC-Introduction
Mythili Shankar
 
DATABASE Lecture 1 and 2.pptx
RUBAB79
 
DBMS basics and normalizations unit.pptx
shreyassoni7
 
unit8_jdbc.pdf mysql and java jdbc connection
Indu32
 
Jdbc
phanleson
 
jdbc
shreeuva
 
Final Database Connectivity in JAVA.ppt
TabassumMaktum
 
Jdbc introduction
Rakesh Kumar Ray
 
DATABASE MANAGEMENT SYSTEM-MRS. LAXMI B PANDYA FOR 25TH AUGUST,2022.pptx
Laxmi Pandya
 
Jdbc sasidhar
Sasidhar Kothuru
 
Java Database Connectivity (JDBC)
Pooja Talreja
 
data base system to new data science lerne
tarunprajapati0t
 
Advanced JAVA
Rajvi Vaghasiya
 
Java database programming with jdbc
sriram raj
 
Java and Database - Interacting with database
Amol Gaikwad
 
Ad

More from Gary Yeh (10)

PDF
Servlet and JSP
Gary Yeh
 
PDF
Introduction of openGL
Gary Yeh
 
PDF
Basic Understanding and Implement of Node.js
Gary Yeh
 
PDF
Run-time of Node.js : V8 JavaScript Engine
Gary Yeh
 
PDF
Linux Char Device Driver
Gary Yeh
 
PDF
JQuery UI
Gary Yeh
 
PDF
jQuery Mobile and JavaScript
Gary Yeh
 
PDF
JQuery mobile
Gary Yeh
 
PDF
Html5 canvas
Gary Yeh
 
PDF
Git Workflow
Gary Yeh
 
Servlet and JSP
Gary Yeh
 
Introduction of openGL
Gary Yeh
 
Basic Understanding and Implement of Node.js
Gary Yeh
 
Run-time of Node.js : V8 JavaScript Engine
Gary Yeh
 
Linux Char Device Driver
Gary Yeh
 
JQuery UI
Gary Yeh
 
jQuery Mobile and JavaScript
Gary Yeh
 
JQuery mobile
Gary Yeh
 
Html5 canvas
Gary Yeh
 
Git Workflow
Gary Yeh
 

Recently uploaded (20)

PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PPTX
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
Human Resources Information System (HRIS)
Amity University, Patna
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 

Database and Java Database Connectivity

  • 1. Database and Java Database Connectivity Gary 2013/06/13
  • 2. Outline • Database • Distributed database • Relational Database • JDBC • JDBC Implementation • Future Work
  • 3. Database • What is database? – A database is an organized collection of data. The data is typically organized to model relevant aspects of reality (for example, the availability of rooms in hotels), in a way that supports processes requiring this information (for example, finding a hotel with vacancies).
  • 4. Database • Database system consists of – User – Data – Hardware • Where data resides – Software • Database management system(DBMS) • Controls storage and retrieval
  • 5. Database • The advantage of database – Reduce redundancy – Avoid inconsistency – Share data – Enforce standards – Security restrictions – Data integrity – Balance conflicting requirement
  • 6. Database • Non-database systems – Each application has its own files • Redundant • Lack centralized control
  • 7. Database • Data independence – Applications not dependent on how data stored or accessed – Applications can have different views of data – Change storage/retrieval strategy without changing applications • Data dependency – Change in storage or retrieval technique forces program change
  • 8. Database • Database language – Host languages • Used to access database • Can use high-level languages – Java, C, C++, Visual Basic, COBOL, PL/I, Pascal – Database sublanguage(DSL) • Specifics of database objects and operations • Combination of – Data definition language(DDL) – Data manipulation language(DML)
  • 9. Database • Embedding SQL statements in a host language
  • 10. Distributed database • A distributed database is a database in which storage devices are not all attached to a common processing unit such as the CPU, controlled by a distributed database management system. It may be stored in multiple computers, located in the same physical location; or may be dispersed over a network of interconnected computers.
  • 11. Distributed database • Pros – Local autonomy or site autonomy • a department can control the data about them (as they are the ones familiar with it) – Protection of valuable data • if there were ever a catastrophic event such as a fire, all of the data would not be in one place, but distributed in multiple locations – Modularity • systems can be modified, added and removed from the distributed database without affecting other modules – Continuous operation • even if some nodes go offline (depending on design, like backup)
  • 12. Distributed database • Cons – Complexity – Economics – Security – Difficult to maintain integrity
  • 13. Relational Database • A relational database is a database that has a collection of tables of data items, all of which is formally described and organized according to the relational model.
  • 14. Relational Database • Composed of tables – Rows called records(tuples) – Columns are fields(attributes) • First field usually primary key – Unique for each record – Primary key can be more than one field – Cannot allow null values
  • 16. Relational Database • Operations – Projection • Taking a subset of a table – Join • Combining tables to form a larger on (by foreign key)
  • 18. Relational Database • Advantages of relational database – Tables easy to use, understand, and implement – Projection and join operations easy to implement – Easy to modify – Great clarity and visibility
  • 19. JDBC • JDBC 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 ODBC-accessible data source in the JVM host environment.
  • 21. JDBC • There are four type of JDBC – JDBC bridge – Native-API bridge – JDBC-Net – Native-Protocol
  • 22. JDBC • JDBC bridge • Ex: Microsoft Access Database Java APP JDBC API JDBC-ODBC Bridge ODBC API ODBC Layer DB
  • 23. JDBC • Native-API bridge Java APP JDBC API Native-API Bridge Native API DB
  • 24. JDBC • JDBC-Net Java APP JDBC API JDBC-Net Middleware or Server DB
  • 25. JDBC • Native-Protocol • Ex: MySQL Java APP JDBC API Native-Protocol DB
  • 27. JDBC Implementation – Has classes and Interfaces for using relational databases – Implements interface Connection – Manages connection between database and program 4 import java.sql.*; 11 private Connection connection;
  • 28. JDBC Implementation – Database URL(location) username to log in password – URL • Protocol for communcation(jdbc) • Subprotocol(odbc) • Database name(Books) 19 String url = "jdbc:odbc:Books"; 20 String username = "anonymous"; 21 String password = "guest";
  • 29. JDBC Implementation – Static method forName () – Static method getconnection • Attempt connection to database • Name and password required 25 Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" ); 27 connection = DriverManager.getConnection( 28 url, username, password );
  • 30. JDBC Implementation • Other JDBC driver usage – MySQL – Oracle – Sybase – Postgresql
  • 31. JDBC Implementation – The statement object • Submits query to database – Returns resultset object containing results – Statement.executeUpdate • Change data in database – Statement.executeQuery • Only query 49 Statement statement; 55 statement = connection.createStatement(); 53 String query = "SELECT * FROM Authors"; 50 ResultSet resultSet; 56 resultSet = statement.executeQuery( query );
  • 32. JDBC Implementation – Statement closed when done – Unlock database 58 statement.close();
  • 34. Future Wrok • Servelets – A servlet is a Java programming language class used to extend the capabilities of a server. Although servlets can respond to any types of requests, they are commonly used to extend the applications hosted by web servers, so they can be thought of as Java Applets that run on servers instead of in web browsers.