Font size
WorksheetsJDBC
Total questions: 67
Worksheet time: 34mins
Which packages contain the JDBC classes?
java.jdbc and javax.jdbc
java.jdbc and java.jdbc.sql
java.sql and javax.sql
java.rdb and javax.rdb
Which type of Statement can execute parameterized queries?
PreparedStatement
ParameterizedStatement
ParameterizedStatement and CallableStatement
All kinds of Statements (i.e. which implement a sub interface of Statement)
Which of the following tasks are associated with JDBC library?
Making a connection to a database.
Creating SQL or MySQL statements.
Executing SQL or MySQL queries in the database.
All of these
Expand JDBC
(a)
_____________ interface handles the communications with the database server
DriverManager
Driver
Statement
None of these
___________ interface with all methods for contacting a database.
ResultSet
Statement
Connection
Driver
The third step involved in JDBC application is ____________
Execute Query
Establish Connection
importing packages
Register the Driver
In Type 2 Driver, JDBC API calls are converted into native _____________ API calls, which are unique to the database
C/C++
Java
JavaScript
Visual Programming
Type 4 Driver is also called as (a)
(a) should be imported to use SQL statements
The most common approach to register a driver is to use Java's (a) method.
To open a connection, DriverManager. (a) () is to be used.
Which method returns an integer as its result?
execute()
executeUpdate()
executeQuery()
extract()
Which interface will NOT accept input parameters
Statement
PreparedStatement
CallableStatement
PrepareStatement
All parameters in JDBC are represented by the ? symbol, which is known as the (a) .
in a ResultSet object, the ___________ methods to retrieve the value of a given column.
POST()
GET()
setXXX()
getXXX()
We bind values to _________ parameters with the setXXX methods
OUT
IN
INPUT
OUTPUT
The corresponding SQL type for the boolean JAVA type is_____
BOOLEAN
BIT
BOOL
BYTE
(a) method returns the total number of columns in the ResultSet object.
_____________interface is used to execute stored procedures.
Statement
PreparedStatement
CallableStatement
execute
(a) method is used to create an object of the class ResultSetMetaData.
What is the return type of executeQuery() method?
int
ResultSet
array
none of the above
what is the package name of "Class"?
java.util
java.sql
java.lang
java.io
What is the return type of executeUpdate() method?
byte
short
int
long
What is true about DriverManager class?
It is class from java.lang package
It is a class from java.sql package
It is a interface from java.sql package
It is a class from java.lang package
Which of the following encapsulates an SQL statement which is passed to the database to be parsed, compiled, planned and executed?
DriverManager
JDBC driver
Connection
Statement
Which of the following is correct about PreparedStatement?
Used when you plan to use the SQL statements many times.
The PreparedStatement interface accepts input parameters at runtime.
Both of the above.
None of the above.
what is true about getConnection() method?
It is a static method from DriverManager class
It is a non static method from DriverManager class
It is a static method from DriverManager interface
It is a non static method from DriverManager interface
Which package contains JDBC classes and interfaces?
java.lang
java.io
java.sql
java.jdbc
Which method is used for an SQL statement that is executed frequently?
prepareStatement
prepareCall
createStatement
None of the above
Which of the following required to be closed to close database operations?
ResultSet
Statement
Connection
All of the above.
What does the Class.forName("MyClass") do?
Loads the class MyClass.
Execute any static block code of MyClass.
Returns an instance of MyClass.
All of the above.
Which of the following contains both date and time?
java.io.date
java.sql.date
java.util.date
java.util.dateTime
What is the output when run with a JDBC 4.0 driver if the "demo" database exists and contains an empty "users" table?
0
1
The code does not compile.
The code compiles but throws an exception at runtime.
Which resources have their close() method called when this code runs?
No close() methods are called.
Only Statement
Only Statement and Connection
Only Statement and ResultSet
When the message “No Suitable Driver” occurs?
When the driver is not registered by Class.forname() method
When the user name, password and the database does not match
When the JDBC database URL passed is not constructed properly
When the type 4 driver is used
Which packages contain the JDBC classes?
java.sql.jdbc
java.sql
javax.sql
java.jdbc.sql
Which packages contain the JDBC classes?
java.sql.jdbc
java.sql
javax.sql
java.jdbc.sql
Which method is used to execute DML statements in JDBC?
execute()
executeUpdate()
executeQuery()
prepareStatement
Which class or interface contains the transaction control methods setAutoCommit(),commit(), and rollback()?
Statement
Connection
ResultSet
none of the above
Which character is used to represent an input parameter in CallableStatement?
%-Percentage symbol
#-hash
?-Question Mark
*-star
When the message “No Suitable Driver” occurs ?
When the type 4 driver is used?
When the driver is not registered by Class.forName() method
When the JDBC database URL passed is not constructed properly
When the user name, password and the database does not match
What does setAutoCommit(false) do?
commits transaction after each query
explicitly commits transaction
does not commit transaction automatically after each query
never commits transaction
For inserting data into database Which Interface is used in JDBC Program?
Statement
PreparedStatement
CallableStatement
ParameterisedStatement
Write the statement for establishing data base Connection in JDBC.
(a)
Which jar file should be set in the classpath for loading jdbc driver?
odbc.jar
ojdbc14.jar
ojdbc23.jar
jdbco20.jar
Write a JDBC Program to retrieve the Student data from Student Table?
What are the methods in Statement Interface?
public ResultSet executeQuery(String sql): is used to execute SELECT query. It returns the object of ResultSet.
public int executeUpdate(String sql): is used to execute specified query, it may be create, drop, insert, update, delete etc.
public boolean execute(String sql): is used to execute queries that may return multiple results.
public int[] executeBatch(): is used to execute batch of commands.
This method is for retrieving a String Value(SQL type VARCHAR) and assigning to String Object.
getVarchar()
getString()
getObject()
getInt()
What are the Interfaces available in JDBC?
Connection interface
PreparedStatement interface
ResultSet interface
RowSet interface
What is return type of executeUpdate() method ?
int
String
Date
ResultSet
