CSE 344: Section 6
Indexing +
HW6 Flights App
May 4th, 2023
Administrivia
Indexing
Indexes
Example
Types of Indexes
Never store passwords in plaintext!
Hashing
Salting
HW6 Hashing/Salting
HW6 Demo
PreparedStatements
String rawQuery = “SELECT * FROM Flights WHERE origin_city = ? AND day_of_month = ?”;
PreparedStatement ps = conn.prepareStatement(rawQuery); // Pre-compiles the query into a PreparedStatement Object
ps.clearParameters(); // Clears parameters from previous use
ps.setString(1, originCity); // Sets the first parameter (the first “?”) to the value of the variable “originCity”
ps.setInt(2, dayOfMonth); // Sets the second parameter (the second “?”) to the value of the variable “dayOfMonth”
ResultSet rs = ps.executeQuery(); // Executes the query and stores the ResultSet in the variable “rs”
ResultSet
// ... continued from previous slide
ResultSet rs = ps.executeQuery();
while (rs.next()) { // check if there is another row and move to the next row
String destCity = rs.getString(“dest_city”); // Gets the value of the attribute “dest_city” for the current row
...
} // When `next` finally returns false, we know we’ve seen every row
rs.close(); // Remember to close the ResultSet
Final HW6 Notes