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

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

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

A.
DriverManager.loadDriver (“org.xyzdata.jdbc.NetworkDriver”);

B.
Class.forName(“org.xyzdata.jdbc-NetworkDriver”);

C.
Connection con = Connection.getDriver
(“jdbc:xyzdata://localhost:3306/EmployeeDB”);

D.
Connection con = DriverManager.getConnection
(“jdbc:xyzdata://localhost:3306/EmployeeDB”);

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.
Note:
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.



Leave a Reply 2

Your email address will not be published. Required fields are marked *