wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JDBC_Objective_Exam_2

Total questions: 15

Worksheet time: 14mins

Name
Class
Date
1.

Which class or interface contains the transaction control methods setAutoCommit(),commit(), and rollback()?

a)

Statement

b)

Connection

c)

ResultSet

d)

none of the above

2.

Which character is used to represent an input parameter in CallableStatement?

a)

%-Percentage symbol

b)

#-hash

c)

?-Question Mark

d)

*-star

3.

When the message “No Suitable Driver” occurs ?

a)

When the type 4 driver is used?

b)

When the driver is not registered by Class.forName() method

c)

When the JDBC database URL passed is not constructed properly

d)

When the user name, password and the database does not match

4.

What does setAutoCommit(false) do?

a)

commits transaction after each query

b)

explicitly commits transaction

c)

does not commit transaction automatically after each query

d)

never commits transaction

5.

For inserting data into database Which Interface is used in JDBC Program?

a)

Statement

b)

PreparedStatement

c)

CallableStatement

d)

ParameterisedStatement

6.

Write the code for loading a Type-4 driver in JDBC program.

(a)  

7.

What are different Exceptions thrown in JDBC?

(a)  

8.

Write the statement for establishing data base Connection in JDBC.

(a)  

9.

Which jar file should be set in the classpath for loading jdbc driver?

a)

odbc.jar

b)

ojdbc14.jar

c)

ojdbc23.jar

d)

jdbco20.jar

10.

Write a JDBC Program to retrieve the Student data from Student Table?

4 lines
11.

What are the correct sequence of steps to connect any database using JDBC ?

a)

import packages,load or register the driver class,establish connection,create the statement,execute queries,close the connection

b)

establish connection,import packages,load or register the driver class,execute queries,create the statement,close the connection

c)

create the statement,import the packages,establish connection,import packages,load or register the driver class,execute queries,close the connection

d)

establish connection,create the statement,import the packages,import packages,load or register the driver class,execute queries,close the connection

12.

What are the methods in Statement Interface?

a)

public ResultSet executeQuery(String sql): is used to execute SELECT query. It returns the object of ResultSet.

b)

public int executeUpdate(String sql): is used to execute specified query, it may be create, drop, insert, update, delete etc.

c)

public boolean execute(String sql): is used to execute queries that may return multiple results.

d)

public int[] executeBatch(): is used to execute batch of commands.

13.

This method is for retrieving a String Value(SQL type VARCHAR) and assigning to String Object.

a)

getVarchar()

b)

getString()

c)

getObject()

d)

getInt()

14.

What are the Interfaces available in JDBC?

a)

Connection interface

b)

PreparedStatement interface

c)

ResultSet interface

d)

RowSet interface

15.

What is return type of executeUpdate() method ?

a)

int

b)

String

c)

Date

d)

ResultSet