[go: up one dir, main page]

0% found this document useful (0 votes)
6 views2 pages

2mark Answer Ajava

Uploaded by

iamhchandan2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

2mark Answer Ajava

Uploaded by

iamhchandan2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

2-MARKS

1. JDBC API Components:


- DriverManager: Manages a list of database drivers.
- Driver: A driver interfaces with the database to handle communications.
- Connection: Establishes a connection with the database.
- Statement: Executes SQL queries and retrieves results.
- ResultSet: Represents the result set of a database query.
- SQLException: Handles exceptions generated during interactions with the database.

2. Key Components of Hibernate:


- SessionFactory: Creates and manages sessions.
- Session: Manages the connection with the database and provides CRUD operations.
- Transaction: Represents a unit of work that should be done in an atomic manner.
- Query: Executes queries written in Hibernate Query Language (HQL).
- Mapping: Represents the mapping between Java classes and database tables.

3. Servlet Lifecycle Methods:


- Init(): Initializes the servlet.
- Service(): Handles client requests.
- Destroy(): Cleans up the resources.

4. ServletConfig vs. ServletContext:


- ServletConfig: It provides initialization parameters for a specific servlet.
- ServletContext: It provides configuration for the entire web application and is accessible to all servlets within the
same application.

5. execute(), executeQuery(), and executeUpdate():


- execute(): Can be used for any kind of SQL statement and returns a boolean to indicate the type of result.
- executeQuery(): Specifically used for executing SELECT statements and returns a ResultSet containing the query
results.
- executeUpdate(): Executes INSERT, UPDATE, DELETE, or DDL statements and returns an integer indicating the
number of rows affected.

6. Statement vs. PreparedStatement interface:


- Statement: Precompiled SQL statement which is executed in a single step but may expose you to SQL injection
attacks.
- PreparedStatement: Precompiles SQL statements and allows parameterized queries, preventing SQL injection
attacks and improving performance for repeated execution of the same statement.

7. Web Server vs. Application Server:


- Web Server: Handles HTTP requests, serves static content, and may support scripting languages (e.g., Apache,
Nginx).
- Application Server: Provides a full range of services to deploy applications, including support for EJBs, database
connectivity, messaging, etc. (e.g., JBoss, WebLogic).

8. GET vs. POST methods:


- GET: Requests data from a specified resource and appends data to the URL. Limited in the amount of data it can
handle.
- POST: Submits data to be processed to a specified resource. It sends data in the body of the HTTP request,
allowing for larger data transmission compared to GET.
9. HttpServletRequest vs. HttpServletResponse:
- HttpServletRequest: Represents the request made by the client to the server. It contains information about the
request, such as parameters, headers, and the body of the request.
- HttpServletResponse: Represents the response generated by the server and sent back to the client. It contains
methods to set response headers, content type, and send data back to the client.

10. SessionFactory:
- In Hibernate, the SessionFactory is a factory class used to create sessions. It's responsible for creating sessions and
caching information that Hibernate uses to interact with the database. It's typically a heavyweight object and is
thread-safe, designed to be created only once in an application.

11. Cookies in Servlets:


- Cookies are small pieces of data stored on the client-side by the web browser. In servlets, you can create cookies
using the `javax.servlet.http.Cookie` class. These cookies can store information like user preferences, session
identifiers, etc. They are sent back and forth between the client and the server with each HTTP request and
response.

12. ResultSet:
- In the context of JDBC, a ResultSet is a Java object that represents the data retrieved from a database after
executing an SQL query. It provides methods to traverse and manipulate this data. It essentially encapsulates the
result of a database query.

13. JSP (JavaServer Pages) and its purpose:


- JSP is a technology that helps in creating dynamic web pages. It allows embedding Java code in HTML pages,
enabling the creation of web content that's dynamic and can interact with Java objects. JSP simplifies the process
of developing web-based applications by separating the presentation layer from the business logic.

14. Built-in objects of JSP:


- request: Represents an HTTP request made by the client and provides access to request parameters, headers, etc.
- response: Represents the HTTP response generated by the server and allows setting response properties like
content type, headers, etc.

15. Role of Model, View, and Controller in MVC:


- Model: Represents the data and business logic of the application. It interacts with the database, processes data,
and contains the application's business rules.
- View: Represents the presentation layer that displays the data to the user. It's responsible for rendering the user
interface based on the data provided by the model.
- Controller: Acts as an intermediary between the model and the view. It processes user requests, interacts with the
model to retrieve data, and updates the view accordingly. It controls the flow of the application.

You might also like