JDBC Database SQL - Quiz Explanation
JDBC and database concepts
The answers you selected are indicated below, along with text that explains the correct answers.
1.
What is the main advantage of using JDBC to access a database?
Please select the best answer.
A.
Your code needs to know nothing about the structure of the database
B.
Your servlet will be faster
C.
Your code will use fewer database connections
D.
It is the only way to get information from a database when you write in Java
The correct answer is A.
Using JDBC insulates you from knowledge of the database in fact, you could even change from Access to Oracle and not a line of code would need to be adjusted. B is incorrect because JDBC is not necessarily faster than some special-purpose code you might write yourself. C is incorrect because the way you access the database has nothing to do with how many database connections you open. D is incorrect because there are many ways to get information from a database in a Java program JDBC is the easiest to use.
2.
What does the SQL statement
SELECT NAME FROM PEOPLE WHERE AGE=25
return?
Please select the best answer.
A.
The NAME and AGE field on every record in the PEOPLE table
B.
The NAME field on every record in the PEOPLE table with 25 in the AGE field
C.
A count of how many records in the PEOPLE table have 25 in the AGE field
D.
A count of how many different NAME values in the PEOPLE table are on records with 25 in the AGE field
The correct answer is B.
The SELECT statement returns actual data, not a count. The NAME field is specified right after the SELECT, so only names will be returned. The WHERE clause restricts this selection only to records with 25 in the AGE field.
3.
Which of the following is a good reason to use the JDBC-ODBC bridge?
Please select the best answer.
A.
More of the users who load your Web pages are likely to have ODBC drivers installed than pure JDBC drivers
B.
ODBC code is faster than the equivalent JDBC code
C.
More database vendors have implemented ODBC drivers than JDBC drivers
D.
You write simpler coding using the bridge than using a pure JDBC driver
The correct answer is C.
If you want to use a database on your Web server machine that has no JDBC driver, but has an ODBC driver, your only choice is to use the bridge. A is incorrect because the drivers installed on your users computers are irrelevant; the database processing happens on the server. B is incorrect because speed is not the issue driver availability is. D is incorrect because your code doesnt become simpler or more complex when you use the bridge the only difference is the string you use when loading the driver.