JDBC_SQLINJ_AUT Flashcards
What is JDBC short for?
JDBC = Java DataBase Connectivity
Functions of JDBC?
JDBC is Java’s call-level interface to SQL
DBMS’s.
– A library with operations that give full access
to relational databases, including:
• Creating, dropping or altering tables, views, etc.
• Modifying data in tables
• Querying tables for information
Explain JDBC
JDBC Objects
• JDBC is a library that provides a set of classes
and methods for the user:
– DriverManager
• Handles connections to different DBMS. Implementation
specific.
– Connection
• Represents a connection to a specific database.
– Statement, PreparedStatement
• Represents an SQL statement or query.
– ResultSet
• Manages the result of an SQL query.
Explain statement object.
2 fundamental methods of statement objects?
Exceptions in JDBC?
How to Execute Queries.
Which commando holds the results of an SQL query?
Important note on ResultsSet.
ResultSet is not a result set!
• Remember a ResultSet is more like a
cursor than an actual set – it is an
interface to the rows in the actual result
set.
• A Statement object can have one result
at a time. If the same Statement is used
again for a new query, any previous
ResultSet for that Statement will no
longer work!
If we need information from more than one table,
there are two different programming patterns for
doing so:
Two approaches
• If we need information from more than one table,
there are two different programming patterns for
doing so:
– Joining tables in SQL
• Join all the tables that we want the information from in a
single query (like we would in SQL), get one large result set
back, and use a ResultSet to iterate through this data.
– Use nested queries in Java
• Do a simple query on a single table, iterate through the
result, and for each resulting row issue a new query to the
database (like in the example on the previous page, but
without the error).
Example of Joining in SQL.
Example using nested queries in JAVA.
Comparison of Joining in SQL and Nested Queries in JAVA
Comparison
• Joining in SQL
– Requires only a single query.
– Everything done in the DBMS, which is good at
optimising.
• Nested queries
– Many queries to send to the DBMS
• communications/network overhead
• compile and optimise many similar queries
– Logic done in Java, which means optimisations must
be done by hand.
– Limits what can be done by the DBMS optimiser.
What does Push complexity to DBMS means?