Escolar Documentos
Profissional Documentos
Cultura Documentos
23.1 Introduction
• Database
– Collection of data
• DBMS
– Database management system
– Stores and organizes data
• SQL
– Relational database
– Structured Query Language
• RDBMS
– Relational database management system
– Cloudscape 5.0.4
• www.ibm.com/software/data/cloudscape
• JDBC
– Java Database Connectivity
– JDBC driver
• Relational database
– Table
• Rows, columns
– Primary key
• Unique data
• SQL statement
– Query
Department Location
413 New Jersey
611 Orlando
642 Los Angeles
Fig. 23.2 Result of selecting distinct Department and Location data from the Employee table.
publisherID publisherName
1 Prentice Hall
2 Prentice Hall PTG
Fig. 23.6 Data from the publishers table.
authorID authorID isbn
firstName isbn title
lastName editionNumber
copyright
publishers publisherID
1
publisherID imageFile
publisherName price
23.4 SQL
• SQL overview
• SQL keywords
SQL keyword Description
SELECT Retrieves data from one or more tables.
FROM Tables involved in the query. Required in every
SELECT.
WHERE Criteria for selection that determine the rows to be
retrieved, deleted or updated.
GROUP BY Criteria for groupin g rows.
ORDER BY Criteria for ordering rows.
INNER JOIN Merge rows from multiple tables.
INSERT Insert rows into a specified table.
UPDATE Update rows in a specified table.
DELETE Delete rows from a specified table.
Fig. 23.12 SQL query keywords.
• Connect to a database
• Query the database
• Display the results of the query
• DisplayAuthors
– Retrieves the entire authors table
– Displays the data in a JTextArea
DisplayQueryRes
ults for
querying
database books.
Program output
• Stored procedures
– Store SQL statements in a database
– Invoke SQL statements by programs accessing the database
• Interface CallableStatement
– Receive arguments
– Output parameters