SlideShare uma empresa Scribd logo
1 de 34
Baixar para ler offline
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.

Mais conteúdo relacionado

Mais procurados

Jdbc (database in java)
Jdbc (database in java)Jdbc (database in java)
Jdbc (database in java)
Maher Abdo
 

Mais procurados (20)

Jdbc Ppt
Jdbc PptJdbc Ppt
Jdbc Ppt
 
JDBC Architecture and Drivers
JDBC Architecture and DriversJDBC Architecture and Drivers
JDBC Architecture and Drivers
 
jdbc document
jdbc documentjdbc document
jdbc document
 
Jdbc (database in java)
Jdbc (database in java)Jdbc (database in java)
Jdbc (database in java)
 
JDBC
JDBCJDBC
JDBC
 
JDBC Connectivity Model
JDBC Connectivity ModelJDBC Connectivity Model
JDBC Connectivity Model
 
Overview Of JDBC
Overview Of JDBCOverview Of JDBC
Overview Of JDBC
 
Jdbc drivers
Jdbc driversJdbc drivers
Jdbc drivers
 
Ajp notes-chapter-05
Ajp notes-chapter-05Ajp notes-chapter-05
Ajp notes-chapter-05
 
Jdbc connectivity in java
Jdbc connectivity in javaJdbc connectivity in java
Jdbc connectivity in java
 
Jdbc
JdbcJdbc
Jdbc
 
JDBC
JDBCJDBC
JDBC
 
Java database connectivity
Java database connectivityJava database connectivity
Java database connectivity
 
JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...
JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...
JDBC,Types of JDBC,Resultset, statements,PreparedStatement,CallableStatements...
 
Jdbc complete
Jdbc completeJdbc complete
Jdbc complete
 
Jdbc connectivity
Jdbc connectivityJdbc connectivity
Jdbc connectivity
 
Basic Java Database Connectivity(JDBC)
Basic Java Database Connectivity(JDBC)Basic Java Database Connectivity(JDBC)
Basic Java Database Connectivity(JDBC)
 
Jdbc drivers
Jdbc driversJdbc drivers
Jdbc drivers
 
Jdbc architecture and driver types ppt
Jdbc architecture and driver types pptJdbc architecture and driver types ppt
Jdbc architecture and driver types ppt
 
Java database connectivity with MySql
Java database connectivity with MySqlJava database connectivity with MySql
Java database connectivity with MySql
 

Destaque (13)

Database Architecture and Basic Concepts
Database Architecture and Basic ConceptsDatabase Architecture and Basic Concepts
Database Architecture and Basic Concepts
 
Organizing Data in a Traditional File Environment
Organizing Data in a Traditional File EnvironmentOrganizing Data in a Traditional File Environment
Organizing Data in a Traditional File Environment
 
Dbms9
Dbms9Dbms9
Dbms9
 
Business intelligence databases and information management
Business intelligence databases and information managementBusiness intelligence databases and information management
Business intelligence databases and information management
 
Distributed Databases
Distributed DatabasesDistributed Databases
Distributed Databases
 
Role of Database Management in Information Systems
Role of Database Management in Information SystemsRole of Database Management in Information Systems
Role of Database Management in Information Systems
 
Application of spss usha (1)
Application of spss usha (1)Application of spss usha (1)
Application of spss usha (1)
 
Database system architecture
Database system architectureDatabase system architecture
Database system architecture
 
Introduction To SPSS
Introduction To SPSSIntroduction To SPSS
Introduction To SPSS
 
Statistical Package for Social Science (SPSS)
Statistical Package for Social Science (SPSS)Statistical Package for Social Science (SPSS)
Statistical Package for Social Science (SPSS)
 
Spss
SpssSpss
Spss
 
Spss lecture notes
Spss lecture notesSpss lecture notes
Spss lecture notes
 
Distributed Database System
Distributed Database SystemDistributed Database System
Distributed Database System
 

Semelhante a Database and Java Database Connectivity

History of database processing module 1 (2)
History of database processing module 1 (2)History of database processing module 1 (2)
History of database processing module 1 (2)
chottu89
 
A Survey of Advanced Non-relational Database Systems: Approaches and Applicat...
A Survey of Advanced Non-relational Database Systems: Approaches and Applicat...A Survey of Advanced Non-relational Database Systems: Approaches and Applicat...
A Survey of Advanced Non-relational Database Systems: Approaches and Applicat...
Qian Lin
 
DBMS basics and normalizations unit.pptx
DBMS basics and normalizations unit.pptxDBMS basics and normalizations unit.pptx
DBMS basics and normalizations unit.pptx
shreyassoni7
 
NoSQL-Database-Concepts
NoSQL-Database-ConceptsNoSQL-Database-Concepts
NoSQL-Database-Concepts
Bhaskar Gunda
 

Semelhante a Database and Java Database Connectivity (20)

Revision
RevisionRevision
Revision
 
History of database processing module 1 (2)
History of database processing module 1 (2)History of database processing module 1 (2)
History of database processing module 1 (2)
 
L17 Data Source Layer
L17 Data Source LayerL17 Data Source Layer
L17 Data Source Layer
 
introduction to NOSQL Database
introduction to NOSQL Databaseintroduction to NOSQL Database
introduction to NOSQL Database
 
UNIT 5- Other Databases.pdf
UNIT 5- Other Databases.pdfUNIT 5- Other Databases.pdf
UNIT 5- Other Databases.pdf
 
Dbms unit 1
Dbms unit 1Dbms unit 1
Dbms unit 1
 
A Survey of Advanced Non-relational Database Systems: Approaches and Applicat...
A Survey of Advanced Non-relational Database Systems: Approaches and Applicat...A Survey of Advanced Non-relational Database Systems: Approaches and Applicat...
A Survey of Advanced Non-relational Database Systems: Approaches and Applicat...
 
DBMS basics and normalizations unit.pptx
DBMS basics and normalizations unit.pptxDBMS basics and normalizations unit.pptx
DBMS basics and normalizations unit.pptx
 
NoSql
NoSqlNoSql
NoSql
 
UNIT I Introduction to NoSQL.pptx
UNIT I Introduction to NoSQL.pptxUNIT I Introduction to NoSQL.pptx
UNIT I Introduction to NoSQL.pptx
 
CST204 DBMS Module-1
CST204 DBMS Module-1CST204 DBMS Module-1
CST204 DBMS Module-1
 
NoSQL-Database-Concepts
NoSQL-Database-ConceptsNoSQL-Database-Concepts
NoSQL-Database-Concepts
 
Big Data Storage Concepts from the "Big Data concepts Technology and Architec...
Big Data Storage Concepts from the "Big Data concepts Technology and Architec...Big Data Storage Concepts from the "Big Data concepts Technology and Architec...
Big Data Storage Concepts from the "Big Data concepts Technology and Architec...
 
Java Developers, make the database work for you (NLJUG JFall 2010)
Java Developers, make the database work for you (NLJUG JFall 2010)Java Developers, make the database work for you (NLJUG JFall 2010)
Java Developers, make the database work for you (NLJUG JFall 2010)
 
So You Want to Build a Data Lake?
So You Want to Build a Data Lake?So You Want to Build a Data Lake?
So You Want to Build a Data Lake?
 
Rdbms
RdbmsRdbms
Rdbms
 
Complete first chapter rdbm 17332
Complete first chapter rdbm 17332Complete first chapter rdbm 17332
Complete first chapter rdbm 17332
 
No SQL
No SQLNo SQL
No SQL
 
CS3270 - DATABASE SYSTEM - Lecture (1)
CS3270 - DATABASE SYSTEM -  Lecture (1)CS3270 - DATABASE SYSTEM -  Lecture (1)
CS3270 - DATABASE SYSTEM - Lecture (1)
 
IM.pptx
IM.pptxIM.pptx
IM.pptx
 

Mais de Gary Yeh (10)

Servlet and JSP
Servlet and JSPServlet and JSP
Servlet and JSP
 
Introduction of openGL
Introduction  of openGLIntroduction  of openGL
Introduction of openGL
 
Basic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.jsBasic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.js
 
Run-time of Node.js : V8 JavaScript Engine
Run-time of Node.js: V8 JavaScript EngineRun-time of Node.js: V8 JavaScript Engine
Run-time of Node.js : V8 JavaScript Engine
 
Linux Char Device Driver
Linux Char Device DriverLinux Char Device Driver
Linux Char Device Driver
 
JQuery UI
JQuery UIJQuery UI
JQuery UI
 
jQuery Mobile and JavaScript
jQuery Mobile and JavaScriptjQuery Mobile and JavaScript
jQuery Mobile and JavaScript
 
JQuery mobile
JQuery mobileJQuery mobile
JQuery mobile
 
Html5 canvas
Html5 canvasHtml5 canvas
Html5 canvas
 
Git Workflow
Git WorkflowGit Workflow
Git Workflow
 

Último

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Último (20)

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 

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.