Database Querying Flashcards
What are the typical steps in the database connection and query pipeline?
<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>
What does a Statement represent in Java SQL execution and what does it generate upon execution?
Represents an SQL statement
Generates a ResultSet objects
What are the three SQL statements you can create in Java etc?
<ul> <li>Statement</li> <li>Prepared Statement</li> <li>Callable Statement</li> </ul>
What are Statements used for?
Simple SQL with no parameters
What are PreparedStatements used for?
Precompiling SQL statements that may contain parameteres
What are CallableStatements used for?
Executing stored procedures which may have both input and output
What does executeQuery return?
Returns one ResultSet object
What does executeUpdate return?
Returns the number of rows affected by the update
In what singular circumstance would you use Statement?
When you know the EXACT STRING for the query, absolutely no parameters
Why would you use PreparedStatement instead of just inserting input in Statement?
To prevent SQL injections
What is PHP used for?
Sending data to web browser and retrieving data from database
What are some potential problems in dealing with databases?
<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>