JDBC  «Prev  Next »

Database Access Servlets - Quiz

 
Each question is worth one point. Select the best answer for each question.
1. What are the consequences of making your database connection in init()?
Please select the best answer.
  A. Your servlet will be slower
  B. All your users will share one database connection
  C. You must add a getConnection() method to your servlet
  D. Your program will open a new connection for each user that loads the servlet

2. What is the full name of the Connection class discussed in this module?
Please select the best answer.
  A. javax.sql.Connection
  B. java.jdbc.sql.Connection
  C. java.sql.Connection
  D. javax.servlet.Connection

3. What is the name of the class in the java.sql package that represents the information extracted from the database?
Please select the best answer.
  A. Statement
  B. RecordSet
  C. ResultSet
  D. Connection

4. After executing a statement of SQL to get a result set, what must you do before extracting information from the result set with getString()?
Please select the best answer.
  A. Close the database connection
  B. Close the statement object
  C. Reset the result set
  D. Call next() to move to the first record of the result set

5. When a database contains dates, numbers, or other non-string fields, calling getString() for one of those fields:
Please select the best answer.
  A. Will throw an exception
  B. Converts the value to a string
  C. Returns an empty string
  D. Will change the field type in the database


6. What will be the effect of the SQL statement UPDATE PEOPLE SET AGE=20 ?
Please select the best answer.
  A. The records with 20 in the age field will be returned to a result set
  B. The age field from every record in the table will be returned to a result set
  C. The age field on every record in the table will be set to 20
  D. The age field on every record in the database will be set to 20

7. What does it mean when the ResultSet next() method returns false?
Please select the best answer.
  A. Your database connection has been closed
  B. You forgot to close your result set
  C. There is no next record in the result set
  D. Your SQL statement was invalid
Your score is 0.0