Database Querying Flashcards

1
Q

What are the typical steps in the database connection and query pipeline?

A

<ol>
<li>Connect to DBMS</li>
<li>Build up SQL statement in a buffer</li>
<li>Pass buffer to DBMS for execution</li>
<li>Check for succesful completion of statement</li>
<li>For queries, retrieve each row of result</li>
<li>Disconnect from DBMS</li>
</ol>

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

What does a Statement represent in Java SQL execution and what does it generate upon execution?

A

Represents an SQL statement

Generates a ResultSet objects

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

What are the three SQL statements you can create in Java etc?

A
<ul>
<li>Statement</li>
<li>Prepared Statement</li>
<li>Callable Statement</li>
</ul>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are Statements used for?

A

Simple SQL with no parameters

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

What are PreparedStatements used for?

A

Precompiling SQL statements that may contain parameteres

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

What are CallableStatements used for?

A

Executing stored procedures which may have both input and output

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

What does executeQuery return?

A

Returns one ResultSet object

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

What does executeUpdate return?

A

Returns the number of rows affected by the update

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

In what singular circumstance would you use Statement?

A

When you know the EXACT STRING for the query, absolutely no parameters

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

Why would you use PreparedStatement instead of just inserting input in Statement?

A

To prevent SQL injections

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

What is PHP used for?

A

Sending data to web browser and retrieving data from database

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

What are some potential problems in dealing with databases?

A

<ul>
<li>Failure to connect to database server</li>
<li>Failure to select a database</li>
<li>Failure to run a query</li>
<li>Failure to return results from a query</li>
</ul>

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