nerdexam
Oracle

1Z0-804 · Question #73

Which code fragment is required to load a JDBC 3.0 driver?

The correct answer is B. Class.forName("org.xyzdata.jdbc-NetworkDriver"). In previous versions (prior to 4.0) of JDBC, to obtain a connection, you first had to initialize your JDBCdriver by calling the method Class.forName. This methods required an object of type java.sql.Driver. DriverManager: This fully implemented class connects an application to…

Building Database Applications with JDBC

Question

Which code fragment is required to load a JDBC 3.0 driver?

Options

  • ADriverManager.loadDriver ("org.xyzdata.jdbc.NetworkDriver");
  • BClass.forName("org.xyzdata.jdbc-NetworkDriver");
  • CConnection con = Connection.getDriver
  • DConnection con = DriverManager.getConnection

How the community answered

(39 responses)
  • A
    3% (1)
  • B
    85% (33)
  • C
    5% (2)
  • D
    8% (3)

Explanation

In previous versions (prior to 4.0) of JDBC, to obtain a connection, you first had to initialize your JDBCdriver by calling the method Class.forName. This methods required an object of type java.sql.Driver. DriverManager: This fully implemented class connects an application to a data source, which is specified by adatabase URL. When this class first attempts to establish a connection, it automatically loads any JDBC 4.0drivers found within the class path. Note that your application must manually load any JDBC drivers prior toversion 4.0.

Topics

#JDBC driver loading#Class.forName#DriverManager

Community Discussion

No community discussion yet for this question.

Full 1Z0-804 Practice