Which JDBC driver Type(s) can be used in either applet or servlet code?
-
Both Type 1 and Type 2
-
Both Type 1 and Type 3
-
Both Type 3 and Type 4
-
Type 4 only
Type 3 and Type 4 drivers are written in 100% Java. Type 4 communicates directly with the database, while Type 3 uses a middleware server. Because they don't require native client library installations, they are suitable for applets (subject to security sandboxing) and servlets, unlike Type 1 and 2.
To answer this question, we need to understand the different types of JDBC drivers and their compatibility with applet and servlet code.
Option A) Both Type 1 and Type 2 - This option is incorrect because neither Type 1 nor Type 2 JDBC drivers can be used in either applet or servlet code.
Option B) Both Type 1 and Type 3 - This option is incorrect because although Type 1 JDBC drivers can be used in applet or servlet code, Type 3 JDBC drivers cannot.
Option C) Both Type 3 and Type 4 - This option is correct because both Type 3 and Type 4 JDBC drivers can be used in either applet or servlet code.
Option D) Type 4 only - This option is incorrect because Type 4 JDBC drivers can be used in applet or servlet code, but it is not the only type that can be used.
The correct answer is C) Both Type 3 and Type 4. This option is correct because both Type 3 and Type 4 JDBC drivers can be used in either applet or servlet code.