JDBC Versions - Quiz Explanation
The answers you selected are indicated below, along with text that explains the correct answers.
1.
What do programmers use the JDBC 2.1 Core API to perform?
Please select the best answer.
-
A.
Essential database tasks
B.
Essential database design
C.
Essential database testing
D.
Essential database deployment.
The correct answer is A.
JDBC 2.1 Core API is used to perform essential database tasks. Answer B is incorrect because JDBC is not used todesign databases. You use other programs to create databases, such as Java or Microsoft Access.
Answer C is incorrect because you do not test the database with JDBC, you connect to the database with JDBC to access and use the data contained in the database. Managing database deployments are within the scope of the JDBC specification, which makes Answer D incorrect.
2.
What comprises the JDBC 2.0 API?
Please select the best answer.
A.
JDBC 2.0 core API and the JDBC Optional Package API
B.
JDBC 2.1 and J2EE
C.
J2EE and the JDBC Optional Package API
D.
JINI and J2EE classes
The correct answer is A.
JDBC 2.0 API is comprised of the JDBC 2.0 core API and the JDBC Optional Package API.
Answer B is incorrect because JDBC 2.1 is another version of JDBC that comes with J2EE. Answer C is incorrect. J2EE is not packaged with the JDBC Optional Package API. Only JDBC 2.0 API is formally packaged with JDBC Optional Package API. Answer D is incorrect because neither JINI nor J2EE are part of the JDBC specification
3.
Identify the correct statements regarding JDBC.
Please select the best answer.
A.
The JDBC Driver must be loaded explicitly in the code before attempting to create a connection to the database
B.
Starting JDBC 4.0, the JDBC Driver class is not required any more.
C.
Starting JDBC 4.0, the JDBC Driver class is not required to be loaded explicitly in the code any more.
D.
JDBC 4.0 allows loading multiple JDBC Drivers while previous versions did not.
The correct answer is C.
c. To load a JDBC driver in JDBC 1.3, the application code would have to load the Driver class explicitly using
Class.forName method, for example - Class.forName("com.xyz.jdbc.Driver").
However, with JDBC 4.0, applications no longer need to do this.
d. There has never been any restriction on how many JDBC Drivers are allowed to be loaded by an application.
If your application connects to 3 different databases, you can load three different Drivers.
Of course, starting JDBC 4.0, you do not need to load the Driver classes explicitly in the code.
Previously you had to explicitly load them using Class.forName. Applications no longer need to explicitly load JDBC drivers using Class.forName().
The DriverManager methods getConnection and getDrivers have been enhanced to support the Java Standard Edition Service Provider mechanism.
JDBC 4.0 Drivers must include the file META-INF/services/java.sql.Driver.
This file contains the name of the JDBC drivers implementation of java.sql.Driver. For example, to load the my.sql.Driver class, the META-INF/services/java.sql.Driver file would contain the entry:
my.sql.Driver
When the method getConnection is called, the DriverManager will attempt to locate a suitable driver from amongst those loaded at initialization and those loaded explicitly using the same classloader as the current applet or application.