Database Management Systems October 9, 2008: Lecture 12 - Chapters 9 and 26 SQL Application Interface
Database Management Systems October 9, 2008: Lecture 12 - Chapters 9 and 26 SQL Application Interface
October 9, 2008
query processor
security manager system
concurrency manager configuration
index manager languages
DDL:
data data
definition definition data
language data
processor dictionary
Application development requires a
general purpose programming language (GPL)
most end-users do not want to run SQL commands
GPL referred to as “host language”
schema data
SLI: statement level interface
new kinds of statements are added to the host language
(i.e. EXEC SQL)
preprocessor translates new statements into
host language procedures
host language compiler used once preprocessed
CLI: call level interface
interface to SQL supplied as library
applications written entirely in host language
no preprocessing required
Statement level older languages:
Embedded SQL C, COBOL
Dynamic SQL
Cursor operations:
Declaration
Open – execute SELECT to determine result set and initialize
pointer
Fetch – advance pointer and retrieve next row
Close – deallocate cursor
cursor SELECT
Result set
(or pointers to it)
application
Base table
In a call-level interface (in an appropriate language)
SQL can return dynamically sized data structures
ODBC
driver
ODBC
database
If an exception is thrown,
catch the SQLException object
The URL will contain additional information if you are connecting over a
network.
ResultSet result_set = null;
try {
Statement stmt = connection.createStatement();
String sql_command = "select * from EMPLOYEE;";
result_set = stmt.executeQuery(sql_command);
}
catch (SQLException sqlex) { … }
The result set metadata allows you to access the schema of the result.
In this case, we’re extracting all values as strings, other types are possible.
try {
connection.close();
}
catch (SQLException sqlex) { … }