Return to site

JAVA CERTIFICATION QUESTION: Database application with JDBC

· java

Which two of the following statements are correct about JDBC?

  • A. A URL string must start with "jdbc".
  • B. A URL string must contain a database name.
  • C. The Class.forName method must be used to load a driver prior to JDBC 4.0
  • D. Using method Class.forName to load a driver as of JDBC 4.0 results in an exception
  • E. Username and password must always be specified when establishing a connection

#java #certificationquestion #ocp

A database connection URL is a string that your DBMS JDBC driver uses to connect to a database.

It can contain information such as where to search for the database,

the name of the database to connect to, and configuration properties.

The exact syntax of a database connection URL is specified by your DBMS.

The only requirement is that it's the form jdbc:[subprotocol]:[subname].

This means option A is correct while option B isn't.

Option E is incorrect since username and password may not be required - it's database dependent.

Using the Class.forName method to load drivers is a must prior to JDBC 4.0.

This method isn't required for JDBC 4.0+. However, doing so is harmless, and no exception is thrown.

Therefore, option C is correct while option D isn't.

·ꓛ puɐ Ɐ sᴉ ɹǝʍsuɐ ʇɔǝɹɹoɔ ǝɥꓕ