wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

JDBC

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Which of the following method is static and synchronized in JDBC API?

a)

getConnection()

b)

prepareCall()

c)

executeUpdate()

d)

executeQuery()

2.

What does setAutoCommit(false) do?

a)

It will not commit transactions automatically after each query.

b)

It explicitly commits the transaction.

c)

It never commits the transactions.

d)

It will commit transaction automatically after each query.

3.

What is the output if the "demo" database exists and contains an empty "users" table?

a)

0

b)

nothing will be printed

c)

The code does not compile.

d)

The code compiles but throws an exception at runtime.

4.

Which resources have their close() method called when this code runs?

a)

No close() methods are called.

b)

Only Statement

c)

Only Statement and Connection

d)

both Statement and ResultSet

5.

How many rows are added to the colors table from running the following?

a)

None

b)

One

c)

Two

d)

Three

6.

The JDBC-ODBC bridge supports multiple concurrent open statements per condition?

a)

True

b)

False

7.

Which methods are required to load a database driver in JDBC?

a)

a. getConnection()

b)

b. registerDriver()

c)

c. forName()

d)

d. Both b and c

e)

e. both a and c

8.

What is the correct sequence to create a database connection?

i. Import JDBC packages.

ii. Open a connection to the database.

iii. Load and register the JDBC driver.

iv. Execute the statement object and return a query resultset.

v. Create a statement object to perform a query.

vi. Close the resultset and statement objects.

vii. Process the resultset.

viii. Close the connection.

a)

i, ii, iii, v, iv, vii, viii, vi

b)

i, iii, ii, v, iv, vii, vi, viii

c)

ii, i, iii, iv, viii, vii, v, vi

d)

i, iii, ii, iv, v, vi, vii, viii

9.

Which of the following driver is the fastest one?

a)

JDBC-ODBC Bridge Driver

b)

Native API Partly Java Driver

c)

Network Protocol Driver

d)

JDBC Net Pure Java Driver

10.

How many statement objects can be created using a Connection?

a)

only one

b)

more than one

c)

three

d)

two