← Back to list

Advanced JAVA-Concept

All the Important and intreview Concept

Aman Verma · 2026-02-21 03:14 · 0 claps · 2.4 min read
#servlet #jsp #java #technology #database
Open on Medium ↗

Advanced JAVA-Concept

All the Important and intreview Concept

🔷 1. JDBC — ResultSet Interface

✅ What is ResultSet?

  • ResultSet is an interface from java.sql package.
  • It represents the data returned by executing SQL SELECT query.

It allows:

  • Retrieving data from the database
  • Navigating rows
  • Manipulating result data

🔹 Creating ResultSet

Using Statement

Statement stm = con.createStatement();
ResultSet rs = stm.executeQuery("SELECT * FROM emp");

Using PreparedStatement

PreparedStatement ps = con.prepareStatement("SELECT * FROM emp");
ResultSet rs = ps.executeQuery();

🔷 2. Types of ResultSet

1️⃣ Non-Scrollable ResultSet

  • Moves only forward
  • Cannot jump to a specific row
  • Default type
ResultSet.TYPE_FORWARD_ONLY

2️⃣ Scrollable ResultSet

  • Move forward & backward
  • Jump to a specific row
  • Re-read data
ResultSet.TYPE_SCROLL_INSENSITIVE
ResultSet.TYPE_SCROLL_SENSITIVE

🔷 3. Concurrency Mode

ResultSet.CONCUR_READ_ONLY
ResultSet.CONCUR_UPDATABLE

🔷 4. Important ResultSet Methods

MethodDescriptionnext()Move to next rowprevious()Move to previous rowfirst()Move to first rowlast()Move to last rowbeforeFirst()Before first rowafterLast()After last rowabsolute(int row)Move to specific rowrelative(int rows)Move relative position

🔷 5. RowSet

  • Child interface of ResultSet
  • Works with connected & disconnected modes

Types:

  • JdbcRowSet
  • CachedRowSet
  • WebRowSet
  • FilteredRowSet
  • JoinRowSet

🔷 6. RowSetFactory

RowSetFactory rsf = RowSetProvider.newFactory();
CachedRowSet crs = rsf.createCachedRowSet();

🔷 7. CallableStatement (Stored Procedures)

Used to execute:

  • Stored Procedures
  • Functions
CallableStatement cs = con.prepareCall("{call proc_name(?)}");

Register OUT Parameter

cs.registerOutParameter(1, Types.INTEGER);

Procedure vs Function

ProcedureFunctionNo return valueReturns valueIN, OUT, INOUTOnly INUsed for operationsUsed for calculation

🔷 8. Transaction Management

Transaction = Group of operations executed together.

Steps:

  1. Disable AutoCommit
con.setAutoCommit(false);
  1. Execute Querie
  2. Commit or Rollback
con.commit();
con.rollback();

🔷 ACID Properties

  1. Atomicity — All or nothing
  2. Consistency — DB remains consistent
  3. Isolation — Transactions are isolated
  4. Durability — Changes are permanent

🔷 9. Savepoint

Savepoint sp = con.setSavepoint();
con.rollback(sp);

🔷 10. Connection Pooling

  • Improves performance
  • Reuses DB connections
  • Avoids repeated creation & destruction

🔷 11. JDBC Metadata

1️⃣ DatabaseMetaData

DatabaseMetaData dbmd = con.getMetaData();
dbmd.getDatabaseProductName();
dbmd.getDriverName();

2️⃣ ParameterMetaData

ParameterMetaData pmd = ps.getParameterMetaData();
pmd.getParameterCount();

3️⃣ ResultSetMetaData

ResultSetMetaData rsmd = rs.getMetaData();
rsmd.getColumnCount();
rsmd.getColumnName(1);

🔷 12. Servlet

What is a Servlet?

  • Java program running on the server
  • Handles HTTP requests
  • Generates da ynamic response

Servlet Life Cycle

  1. init()
  2. service()
  3. destroy()

Servlet Interface Methods

public void init()
public void service()
public void destroy()
public ServletConfig getServletConfig()
public String getServletInfo()

🔷 13. Creating Servlet (3 Ways)

  1. Implement Servlet
  2. Extend GenericServlet
  3. Extend HttpServlet ✅ (Mostly Used)

HttpServlet Methods

doGet()
doPost()

🔷 14. Request Dispatcher

Used for:

  • Forward
  • Include
RequestDispatcher rd = request.getRequestDispatcher("page.jsp");
rd.forward(request, response);

🔷 15. JSP

Scripting Tags

  1. Scriptlet
<% code %>
  1. Expression
<%= value %>
  1. Declaration
<%! int x=10; %>

Directive Tags

  1. Page
<%@ page contentType="text/html" %>
  1. Include
<%@ include file="header.jsp" %>
  1. Taglib

Action Tags

<jsp:include page="file.jsp"/>🔷 16. MVC Architecture

Model

  • JavaBeans
  • DAO
  • Database

View

  • JSP
  • HTML

Controller

  • Servlet

Flow:

HTML → Servlet → Bean → DAO → DB Servlet → JSP (Display result)

🔷 17. JavaBeans

Rules:

  1. Must implement Serializable
  2. Private variable
  3. Public getter & setter
  4. Public default constructor

🔷 18. Attributes in Servlet

request.setAttribute("name", value);
request.getAttribute("name");
request.removeAttribute("name");
🔷 19. GET vs POST

GETPOSTData in URLData in BodyLess secureMore secureLimited sizeLarge dataUsed for retrievalUsed for submission

🔷 20. Session Tracking

Methods:

  1. Cookies
  2. HttpSession
  3. URL Rewriting
  4. Hidden Fields

🔷 21. Cookie Class

Cookie c = new Cookie("name","value");
c.setMaxAge(60);
response.addCookie(c);

Important Methods:

getName()
getValue()
setValue()
setMaxAge()
getMaxAge()

🔷 22. Session

HttpSession session = request.getSession();
session.setAttribute("user", value);
session.getAttribute("user");
session.invalidate();

🔷 23. Web Server vs Application Server

Web ServerApp ServerHandles HTTPHandles Web + EnterpriseExample: TomcatExample: WebLogic

🔥 Final Summary

You covered:

✔ JDBC ✔ ResultSet ✔ RowSet ✔ Stored Procedures ✔ Transaction Management ✔ Metadata ✔ Servlet ✔ JSP ✔ MVC ✔ JavaBeans ✔ Session ✔ Cookies


메타데이터
post_id
fca591edb8dd
slug
advanced-java-concept-fca591edb8dd
url
https://medium.com/@amn24/advanced-java-concept-fca591edb8dd
canonical_url
https://medium.com/@amn24/advanced-java-concept-fca591edb8dd
author_url
https://medium.com/@amn24
status
ok
fetched_at
2026-06-23 03:48:11