JDBC Drivers, JSP Tags, and ResultSet Implementation

Posted by Anonymous and classified in Computers

Written on in English with a size of 2.86 KB

JDBC Driver Types

Type 1: JDBC-ODBC Bridge

  • Converts JDBC calls to ODBC
  • ❌ Slow, platform dependent, and obsolete

Type 2: Native API Driver

  • Uses database-specific native libraries
  • ⚠️ Faster than Type 1 but platform dependent

Type 3: Network Protocol Driver

  • Uses middleware server to connect
  • 🌐 Platform independent but slower due to network

Type 4: Thin Driver

  • Directly connects to database using pure Java
  • ✅ Fast, platform independent, and most used

Tags in JSP

1. Directive Tags

  • Provide instructions to the JSP container
  • Syntax: <%@ ... %>
  • Example: page, include, taglib

2. Scripting Tags

  • Scriptlet Tag: Write Java code <% ... %>
  • Expression Tag: Display output <%= ... %>
  • Declaration Tag: Declare variables or methods <%! ... %>

3. Action Tags

  • Perform actions like include or forward
  • Syntax: <jsp:... />
  • Example: <jsp:include>, <jsp:forward>

ResultSet and Its Types

In Java Database Connectivity (JDBC), a ResultSet is an object used to store the data returned from a database query (usually a SELECT statement).

1. TYPE_FORWARD_ONLY

  • Cursor moves only forward
  • Cannot go backward
  • Default type

2. TYPE_SCROLL_INSENSITIVE

  • Cursor can move forward and backward
  • Does not reflect changes made in the database

3. TYPE_SCROLL_SENSITIVE

  • Cursor moves in both directions
  • Reflects database changes dynamically

Example of Creating ResultSet Types

Statement st = con.createStatement(
    ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_READ_ONLY
);

RowSet and Its Types

In Java Database Connectivity (JDBC), a RowSet is an advanced version of ResultSet.

1. JdbcRowSet

  • Connected RowSet
  • Works like ResultSet
  • Maintains a continuous database connection

2. CachedRowSet

  • Disconnected RowSet
  • Stores data in memory
  • Can work without a database connection

3. WebRowSet

  • Extension of CachedRowSet
  • Can read/write data in XML format

4. FilteredRowSet

  • Filters data based on conditions
  • Shows only selected rows

5. JoinRowSet

  • Combines data from multiple tables
  • Works like an SQL JOIN

Related entries: