Week 3 Cont Flashcards

1
Q

Statement is okay to use for SQL commands that are fixed, but when user input is required it is best to use _______________.

A

PreparedStatement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does PreparedStatement allow us to do that Statement does not? Why is this better than Statement?

A

use “?” as a placeholder in the SQL statements.

There will never be a conflict between the SQL vars and the program vars.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

T/F - PreparedStatement prevents SQL injection (hacking technique)

A

True.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

PreparedStatement prepQuery=connection.prepareStatement(
“select * from user where name = ?”);
prepQuery.setString(1, name);

How does setString() work in conjunction with with preparedStatement?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How does RowSet extend ResultSet?

A

Resultset must be connected to a DB for the duration

Rowset does not have to always be connected

How well did you know this?
1
Not at all
2
3
4
5
Perfectly