JDBC Driver Types — Suitable for Both Applets and Servlets Which JDBC driver type(s) are appropriate for use in either Java applet code running on a client machine or Java servlet code running on a web server?

Difficulty: Easy

Correct Answer: Both Type 3 and Type 4

Explanation:


Introduction:
JDBC drivers come in different architectures, each with implications for deployment in browsers (applets) and servers (servlets). Understanding which types are pure Java and do not require native libraries or local ODBC layers is vital for portability and security in both environments.


Given Data / Assumptions:

  • Applets historically ran in client browsers with restricted access and no native libraries.
  • Servlets run on the server and can use any driver, but portability is preferred.
  • Type 3 and Type 4 drivers are pure Java and do not rely on local native code.


Concept / Approach:
Type 3 (network protocol) drivers communicate via a middleware server, and Type 4 (thin) drivers talk directly to the DBMS using the database’s wire protocol. Both are written in Java and avoid native dependencies, making them suitable for both applet and servlet contexts. Type 1 relies on ODBC; Type 2 uses native APIs, both unsuitable for applet security sandboxes and less portable in general.


Step-by-Step Solution:
1) Eliminate Type 1 (requires client-side ODBC) and Type 2 (requires native libraries).2) Confirm Type 3 is pure Java with middleware; Type 4 is pure Java with direct protocol.3) Conclude that both Type 3 and Type 4 fit applet and servlet usage.


Verification / Alternative check:
Vendor documentation and Java textbooks traditionally recommend Type 3 or Type 4 for browser and server environments due to their portability and ease of deployment.


Why Other Options Are Wrong:

  • Type 1/2 combinations: Depend on client-side ODBC or native code, problematic for applets.
  • Type 4 only: Type 4 works, but so does Type 3; excluding it is unnecessary.


Common Pitfalls:
Forgetting that applet sandboxes prohibit native libraries, ruling out Types 1 and 2.


Final Answer:
Both Type 3 and Type 4

More Questions from JDBC, Java Server Pages, and MySQL

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion