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.
Ad

Recommended

Jdbc
Jdbc
leminhvuong
 
Java DataBase Connectivity API (JDBC API)
Java DataBase Connectivity API (JDBC API)
Luzan Baral
 
java Jdbc
java Jdbc
Ankit Desai
 
Jdbc
Jdbc
Smit Patel
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivity
Tanmoy Barman
 
Jdbc
Jdbc
Mumbai Academisc
 
Jdbc_ravi_2016
Jdbc_ravi_2016
Ravinder Singh Karki
 
Java- JDBC- Mazenet Solution
Java- JDBC- Mazenet Solution
Mazenetsolution
 
Jdbc Ppt
Jdbc Ppt
Centre for Budget and Governance Accountability (CBGA)
 
JDBC Architecture and Drivers
JDBC Architecture and Drivers
SimoniShah6
 
jdbc document
jdbc document
Yamuna Devi
 
Jdbc (database in java)
Jdbc (database in java)
Maher Abdo
 
JDBC
JDBC
Ankit Desai
 
JDBC Connectivity Model
JDBC Connectivity Model
kunj desai
 
Overview Of JDBC
Overview Of JDBC
Mindfire Solutions
 
Jdbc drivers
Jdbc drivers
Prabhat gangwar
 
Ajp notes-chapter-05
Ajp notes-chapter-05
Ankit Dubey
 
Jdbc connectivity in java
Jdbc connectivity in java
Muthukumaran Subramanian
 
Jdbc
Jdbc
myrajendra
 
JDBC
JDBC
People Strategists
 
Java database connectivity
Java database connectivity
Vaishali Modi
 
JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...
JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...
Pallepati Vasavi
 
Jdbc complete
Jdbc complete
Sandeep Rawat
 
Jdbc connectivity
Jdbc connectivity
arikazukito
 
Basic Java Database Connectivity(JDBC)
Basic Java Database Connectivity(JDBC)
suraj pandey
 
Jdbc drivers
Jdbc drivers
Saurabh Bhartiya
 
Jdbc architecture and driver types ppt
Jdbc architecture and driver types ppt
kamal kotecha
 
Java database connectivity with MySql
Java database connectivity with MySql
Dhyey Dattani
 
Database Architecture and Basic Concepts
Database Architecture and Basic Concepts
Tony Wong
 
Organizing Data in a Traditional File Environment
Organizing Data in a Traditional File Environment
Albrecht Jones
 

More Related Content

What's hot (20)

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

Viewers also liked (13)

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

Similar to Database and Java Database Connectivity (20)

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

More from Gary Yeh (10)

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

Recently uploaded (20)

On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
Hassan Abid
 
Sysinfo OST to PST Converter Infographic
Sysinfo OST to PST Converter Infographic
SysInfo Tools
 
Folding Cheat Sheet # 9 - List Unfolding 𝑢𝑛𝑓𝑜𝑙𝑑 as the Computational Dual of ...
Folding Cheat Sheet # 9 - List Unfolding 𝑢𝑛𝑓𝑜𝑙𝑑 as the Computational Dual of ...
Philip Schwarz
 
Zoneranker’s Digital marketing solutions
Zoneranker’s Digital marketing solutions
reenashriee
 
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
joybepari360
 
Porting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 Webinar
ICS
 
Streamlining CI/CD with FME Flow: A Practical Guide
Streamlining CI/CD with FME Flow: A Practical Guide
Safe Software
 
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Natan Silnitsky
 
Artificial Intelligence Workloads and Data Center Management
Artificial Intelligence Workloads and Data Center Management
SandeepKS52
 
Reimagining Software Development and DevOps with Agentic AI
Reimagining Software Development and DevOps with Agentic AI
Maxim Salnikov
 
Download Adobe Illustrator Crack free for Windows 2025?
Download Adobe Illustrator Crack free for Windows 2025?
grete1122g
 
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Varsha Nayak
 
Introduction to Agile Frameworks for Product Managers.pdf
Introduction to Agile Frameworks for Product Managers.pdf
Ali Vahed
 
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
IFI Techsolutions
 
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Puppy jhon
 
Transmission Media. (Computer Networks)
Transmission Media. (Computer Networks)
S Pranav (Deepu)
 
Making significant Software Architecture decisions
Making significant Software Architecture decisions
Bert Jan Schrijver
 
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
BradBedford3
 
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Safe Software
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
Hassan Abid
 
Sysinfo OST to PST Converter Infographic
Sysinfo OST to PST Converter Infographic
SysInfo Tools
 
Folding Cheat Sheet # 9 - List Unfolding 𝑢𝑛𝑓𝑜𝑙𝑑 as the Computational Dual of ...
Folding Cheat Sheet # 9 - List Unfolding 𝑢𝑛𝑓𝑜𝑙𝑑 as the Computational Dual of ...
Philip Schwarz
 
Zoneranker’s Digital marketing solutions
Zoneranker’s Digital marketing solutions
reenashriee
 
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
joybepari360
 
Porting Qt 5 QML Modules to Qt 6 Webinar
Porting Qt 5 QML Modules to Qt 6 Webinar
ICS
 
Streamlining CI/CD with FME Flow: A Practical Guide
Streamlining CI/CD with FME Flow: A Practical Guide
Safe Software
 
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Async-ronizing Success at Wix - Patterns for Seamless Microservices - Devoxx ...
Natan Silnitsky
 
Artificial Intelligence Workloads and Data Center Management
Artificial Intelligence Workloads and Data Center Management
SandeepKS52
 
Reimagining Software Development and DevOps with Agentic AI
Reimagining Software Development and DevOps with Agentic AI
Maxim Salnikov
 
Download Adobe Illustrator Crack free for Windows 2025?
Download Adobe Illustrator Crack free for Windows 2025?
grete1122g
 
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Varsha Nayak
 
Introduction to Agile Frameworks for Product Managers.pdf
Introduction to Agile Frameworks for Product Managers.pdf
Ali Vahed
 
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
IFI Techsolutions
 
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Puppy jhon
 
Transmission Media. (Computer Networks)
Transmission Media. (Computer Networks)
S Pranav (Deepu)
 
Making significant Software Architecture decisions
Making significant Software Architecture decisions
Bert Jan Schrijver
 
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
Women in Tech: Marketo Engage User Group - June 2025 - AJO with AWS
BradBedford3
 
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Automated Migration of ESRI Geodatabases Using XML Control Files and FME
Safe Software
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 

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.