Week 3 Cont Flashcards
Statement is okay to use for SQL commands that are fixed, but when user input is required it is best to use _______________.
PreparedStatement.
What does PreparedStatement allow us to do that Statement does not? Why is this better than Statement?
use “?” as a placeholder in the SQL statements.
There will never be a conflict between the SQL vars and the program vars.
T/F - PreparedStatement prevents SQL injection (hacking technique)
True.
PreparedStatement prepQuery=connection.prepareStatement(
“select * from user where name = ?”);
prepQuery.setString(1, name);
How does setString() work in conjunction with with preparedStatement?
preparedStatement is interpreted as SQL
setString does a replacement with that is not interpreted as SQL. Anything that an end user inputs is not interpreted as SQL by setString
How does RowSet extend ResultSet?
Resultset must be connected to a DB for the duration
Rowset does not have to always be connected