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

JDBC Questions With Ans

The document contains 30 multiple choice questions about JDBC (Java Database Connectivity). It covers topics like when different JDBC driver errors occur, how to load and register JDBC drivers, performing different types of queries and statements, handling transactions, and key classes and interfaces in the java.sql package.

Uploaded by

saminaflora12
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)
69 views9 pages

JDBC Questions With Ans

The document contains 30 multiple choice questions about JDBC (Java Database Connectivity). It covers topics like when different JDBC driver errors occur, how to load and register JDBC drivers, performing different types of queries and statements, handling transactions, and key classes and interfaces in the java.sql package.

Uploaded by

saminaflora12
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/ 9

Ques1)When the message"No suitable driver" occurs?

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

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

c) When the JDBC database URL passed is not constructed properly

d) When the type 4 driver is used.

Ques2)Which of the following are needed for loading a database

driver in JDBC?

a)registerDriver() method

b)Class.forName()

c)Both A and B

d)getConnection()

Ques3)BLOB,CLOB,ARRAY and REF type columns can be updated in?

a)JDBC 1.0

b)JDBC 4.0

c)JDBC 2.0

d)JDBC 3.0

Ques4)To execute a stored procedure"Total stock" in a database server

which of the following is used?

a)Statement

b)Callable Statement

c)Stored Procedure Statement

d)Prepare Statement

Ques5)Which of the following is false as far as Type4 driver is concerned?


a)Type 4 driver is “native protocol, pure java” driver.

b)Type 4 drivers are 100% Java compatible.

c) Type 4 drivers uses Socket class to connect to the database.

d) Type 4 drivers can not be used with Netscape.

Ques6)Which statement is static and synchronized in JDBC API?

a)executeQuery()

b) executeUpdate()

c) getConnection()

d) prepareCall()

Ques7)Which of the following stament is false as far as different type is

concern in JDBC?

a)Regular Statement

b)Prepared Statement

c)Callable Statement

d)Interim Statement

Ques8)All raw data types should be read and uploaded to the database

as an array of?

a)byte

b)int

c)boolean

d)char

Ques9)Which are the new features adding in to the JDBC 4.0 ?

(a)Auto-loading of JDBC driver class


(b)Connection management enhancements

(c)Support for RowId SQL type

(d)All of the above

Ques10)Which method is used to perform the DML statement in JDBC?

a)execute()

b)executeQuery()

c)executeUpdate()

d)executeResult()

Ques11)What is the disadvantage of Type-4 Native Protocol Driver?

a)At client side, a separate driver is needed for each database.

b) Type-4 driver is entirely written in Java

c) The driver converts JDBC calls into vendor-specific database protocol

d) It does not support to read MySQL data.

Ques12)JDBC is a ..................... interface, which means that it is used to invoke SQL commands
directly?

A) low-level

B) middle-level

C) higher-level

D) user

Ques13)Which JDBC driver Type(s) can be used in either applet or servlet code?

a) Both Type 1 and Type 2


b) Both Type 1 and Type 3

c) Both Type 3 and Type 4

d) Type 4 only

Ques14)Which JDBC driver Type(s) can you use in a three-tier architecture and if the Web server and
the DBMS are running on the same machine?

a) Type 1 only

b) Type 2 only

c) Both Type 3 and Type 4

d) All of Type 1, Type 2, Type 3 and Type 4

Ques15) ODBC is not appropriate for direct use from java because it uses a ..............

a) C interface

b) C# interface

c) java interface

d) Both A and C

Ques16) Which statements about JDBC are true?

a) JDBC is an API to connect to relational-, object- and XML data sources

b) JDBC stands for Java DataBase Connectivity

c) JDBC is an API to access relational databases, spreadsheets and flat files

d) JDBC is an API to bridge the object-relational mismatch between OO programs and relational

databases

Ques17) Which type of driver converts JDBC calls into the network protocol used by the database
management system

directly?

a) Type 1 driver
b) Type 2 driver

c) Type 3 driver

d) Type 4 driver

Ques18) Which type of Statement can execute parameterized queries?

a) PreparedStatement

b) ParameterizedStatement

c) ParameterizedStatement and CallableStatement

d) All kinds of Statements (i.e. which implement a sub interface of Statement)

Ques19) How can you retrieve information from a ResultSet?

a) By invoking the method get(..., String type) on the ResultSet, where type is the database type

b) By invoking the method get(..., Type type) on the ResultSet,

where Type is an object which represents a database type.

c) By invoking the method getValue(...), and cast the result to the desired Java type.

d) By invoking the special getter methods on the ResultSet: getString(...), getBoolean (...),
getClob(...),...

Ques20) What statements are correct about JDBC transactions?


a) A transaction is a set of successfully executed statements in the database

b) A transaction is finished when commit() or rollback() is called on the Connection object,

c) A transaction is finished when commit() or rollback() is called on the Transaction object

d) A transaction is finished when close() is called on the Connection object.

Ques21) What happens if you call deleteRow() on a ResultSet object?

a) The row you are positioned on is deleted from the ResultSet, but not from the database.

b) The row you are positioned on is deleted from the ResultSet and from the database.

c)The result depends on whether the property synchronizeWithDataSource is set to true or false

d) You will get a compile error: the method does not exist because you can not delete rows from a
ResultSet

Ques22) The JDBC-ODBC Bridge supports multiple concurrent open statements per connection?

a) True

b) False

Ques23) 84. try {

85. ResourceConnection con = resourceFactory.getConnection();

86. Results r = con.query("GET INFO FROM CUSTOMER");

87. info = r.getData();

88. con.close();

89. } catch (ResourceException re) {


90. errorLog.write(re.getMessage());

91. }

92. return info;

Which statement is true if a ResourceException is thrown on line 86?

a) Line 92 will not execute.

b) The connection will not be retrieved in line 85.

c) The resource connection will not be closed on line 88.

d) The enclosing method will throw an exception to its caller

Ques24)Which packages contain the JDBC classes?

a)java.jdbc and javax.jdbc

b)java.jdbc and java.jdbc.sql

c) java.sql and javax.sql

d) java.rdb and javax.rdb

Ques25)How can you execute DML statements (i.e. insert, delete, update) in

the database?

a) By making use of the InsertStatement, DeleteStatement or

UpdateStatement classes

b) By invoking the execute(...) or executeUpdate(...) method of a

normal Statement object or a sub-interface object thereof

c) By invoking the executeInsert(...), executeDelete(...) or

executeUpdate(...) methods of the DataModificationStatement object.

d) By making use of the execute(...) statement of the

DataModificationStatement object.
Ques25)What is, in terms of JDBC, a DataSource?

a) A DataSource is the basic service for managing a set of JDBC drivers.

b) A DataSource is the Java representation of a physical data source.

c) A DataSource is a registry point for JNDI-services.

d) A DataSource is a factory of connections to a physical data source.

Ques26)Are prepared statement actually compiled?

a)Yes,They complied

b)No,they are bound by JDBC driver.

Ques27)What is correct about DDL statements (create, grant,...)

a) DDL statements are treated as normal SQL statements, and are executed by calling the execute()
method on a Statement (or a sub interface thereof) object

b) To execute DDL statements, you have to install additional support files

c) DDL statements can not be executed by making use of JDBC, you should use the native database
tools for this.

d) Support for DDL statements will be a feature of a future release of JDBC’

Ques28)Which of the following allows non repeatable read in JDBC Connection?a

a)TRANSACTION_READ_UNCOMMITTED

b) TRANSACTION_READ_COMMITTED

c) TRANSACTION_SERIALIZABLE

d) TRANSACTION_REPEATABLE_READ

Ques29)The class java.sql.Timestamp has its super class as?

a) java.sql.Time
b) java.util.Date

c) java.util.Time

d) None of the above

Ques30) Which driver is called as Thin-driver in JDBC?

a)TYPE-4

b)TYPE-2

c)TYPE-1

d)TYPE-3

You might also like