0% found this document useful (0 votes)
3 views9 pages

JDBC Architecture

The document contains a series of questions and explanations related to JDBC (Java Database Connectivity), including its architecture, drivers, core classes, and methods for database operations. It covers topics such as two-tier and three-tier architectures, types of JDBC drivers, and the use of PreparedStatement for preventing SQL injection. Additionally, it includes programming tasks and explanations of JDBC components and exception handling.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views9 pages

JDBC Architecture

The document contains a series of questions and explanations related to JDBC (Java Database Connectivity), including its architecture, drivers, core classes, and methods for database operations. It covers topics such as two-tier and three-tier architectures, types of JDBC drivers, and the use of PreparedStatement for preventing SQL injection. Additionally, it includes programming tasks and explanations of JDBC components and exception handling.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1.

JDBC stands for:

A) Java Database Connectivity


B) Java Data Control
C) Java Database Class
D) Java Driver Connection

2. ODBC stands for:

A) Open Database Connectivity


B) Object Database Control
C) Open DataBase Class
D) Object Data Connectivity

3. JDBC is used for:

A) GUI design
B) Database connectivity
C) File handling
D) Networking

4. Which package contains JDBC classes?

A) [Link]
B) [Link]
C) [Link]
D) [Link]

🔹 JDBC Architecture
5. JDBC supports:

A) Single-tier
B) Two-tier & Three-tier
C) Four-tier
D) None

6. In two-tier architecture, client communicates


directly with:

A) Server
B) Database
C) Middleware
D) Network

7. In three-tier architecture, middle layer is:

A) Database
B) Application server

C) Client
D) Driver

🔹 JDBC Drivers
8. Type 1 driver is:

A) Native driver
B) JDBC-ODBC bridge
C) Thin driver
D) Network driver

9. Type 4 driver is:

A) Native driver
B) Bridge driver
C) Thin driver
D) ODBC driver

10. Which driver is platform independent?

A) Type 1
B) Type 2
C) Type 3
D) Type 4

🔹 Core JDBC Classes & Interfaces


11. Which class loads drivers?

A) Driver
B) DriverManager
C) Connection
D) Statement

12. Which interface represents database


connection?

A) Driver
B) Connection
C) Statement
D) ResultSet

13. Which interface is used to execute SQL


queries?

A) Connection
B) Statement
C) ResultSet
D) Driver

14. PreparedStatement is used for:

A) Static queries
B) Dynamic queries with parameters
C) Thread handling
D) Exception handling

15. Which interface stores query result?

A) Statement
B) Connection
C) ResultSet
D) Driver

🔹 Database Operations
16. Which method executes
INSERT/UPDATE/DELETE?

A) executeQuery()
B) executeUpdate()
C) execute()
D) run()

17. Which method executes SELECT query?

A) executeUpdate()
B) executeQuery()
C) execute()
D) fetch()

18. ResultSet cursor initially points to:

A) First row
B) Last row
C) Before first row
D) After last row

19. Which method moves cursor to next row?

A) next()
B) previous()

C) first()
D) last()

🔹 Program-Based Questions

20. What will be the output?

Statement st = [Link]();
ResultSet rs = [Link]("SELECT * FROM student");

A) Data inserted
B) Data retrieved
C) Error
D) Nothing

21. What will happen?


PreparedStatement ps = [Link]("INSERT INTO emp
VALUES(?,?)");
[Link](1,101);
[Link](2,"Ram");
[Link]();

A) Data inserted
B) Data deleted
C) Error
D) Data selected

22. Which is safer against SQL injection?

A) Statement
B) PreparedStatement
C) ResultSet
D) Driver

23. Which method closes connection?

A) stop()
B) close()
C) end()
D) terminate()

24. Which exception is commonly used in JDBC?

A) IOException
B) SQLException
C) ArithmeticException
D) NullPointerException
25. What will be the output?

ResultSet rs = [Link]("SELECT COUNT(*) FROM student");

A) Number of records
B) Error
C) Data inserted
D) Nothing

Explain JDBC architecture.


(Explain two-tier and three-tier architecture with diagram.)

List and explain types of JDBC drivers.


(Type 1, Type 2, Type 3, Type 4)

Write steps to connect Java application with database


using JDBC.

Differentiate between Statement and PreparedStatement.

Explain the role of DriverManager and Connection


interface.

What is ResultSet? Explain its types and methods.

Write a Java program to insert data into database using


PreparedStatement.

Write a Java program to retrieve data from database using


ResultSet.

Explain executeQuery() and executeUpdate() methods


with examples.

10

What is SQL injection? How does PreparedStatement


prevent it?

11

Explain JDBC API components (DriverManager,


Connection, Statement, ResultSet).

12

What is the difference between two-tier and three-tier


JDBC architecture?

13

Explain exception handling in JDBC using SQLException.

14

Write steps to create and execute a SELECT query using


JDBC.

15

Explain how to close JDBC resources properly.

You might also like