Font size
WorksheetsWTN_JDBC
Total questions: 50
Worksheet time: 25mins
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)
_____________ driver talks with server-side middleware which then talks to the database
Type 1
Type 2
Type 3
Type 4
(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.
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)
How can you retrieve information from a ResultSet?
By invoking the method get(…, String type) on the ResultSet, where type is the database type
By invoking the method get(…, Type type) on the ResultSet, where Type is an object which represents a database type
By invoking the method getValue(…), and cast the result to the desired Java type.
By invoking the special getter methods on the ResultSet: getString(…), getInt (…), getDouble(…),…
How can you execute a stored procedure in the database?
Call method execute() on a CallableStatement object
Call method executeProcedure() on a Statement object
Call method execute() on a StoredProcedure object
Call method run() on a ProcedureCommand object
Which method is used to perform DML statements in JDBC?
execute()
executeQuery()
executeUpdate()
executeResult()
Which of the following is correct about PreparedStatement?
Prepared statements offer better performance, as they are pre-compiled.
Prepared statements reuse the same execution plan for different arguments rather than creating a new execution plan every time.
Prepared statements use bind arguments, which are sent to the database engine.
All of the above.
In order to transfer data between a database and an application written in the Java programming language, the JDBC API provides which of these methods?
Methods on the ResultSet class for retrieving SQL SELECT results as Java types.
Methods on the PreparedStatement class for sending Java types as SQL statement parameters.
Methods on the CallableStatement class for retrieving SQL OUT parameters as Java types.
All mentioned above
The performance of the application will be faster if you use PreparedStatement interface because query is compiled only once.
True
False
Which method is used to establish the connection with the specified url in a Driver Manager class?
public static void registerDriver(Driver driver)
public static void deregisterDriver(Driver driver)
public static Connection getConnection(String url)
public static Connection getConnection(String url,String userName,String password)
Which driver Network connection is indirect that a JDBC client makes to a middleware process that acts as a bridge to the DBMS server?
JDBC-Net
JDBC-ODBC bridge
Native API as basis
Native protocol as basis
Which is used to call the stored procedures and functions?
CallableStatement Interface
PreparedStatement Interface
All the above
None of the above
What is used to execute parameterized query?
Statement interface
PreparedStatement interface
ResultSet interface
None of the above
ODBC stands for?
Open database connection
Open database concept
Open database communications
None of the above
Which models do the JDBC API support for the database access?
Two-tier models
Three-tier models
Both A & B
None of the above
Which of the following is used to rollback a JDBC transaction?
rollback()
rollforward()
deleteTransaction()
RemoveTransaction()
The method on the result set that tests whether or not there remains at least one unfetched tuple in the result set, is said to be
Fetch method
Current method
Next method
Access method
Which method is used to perform DML statements in JDBC?
execute()
executeQuery()
executeUpdate()
executeResult()
Which of the following describes the correct sequence of the steps involved in making a connection with a database.
1. Loading the driver
2. Process the results.
3. Making the connection with the database.
4. Executing the SQL statements.
1 ,3,4,2
1,2,3,4
1,4,3,2
1,2,4,3
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
_____________ interface handles the communications with the database server
DriverManager
Driver
Statement
None of these
The most common approach to register a driver is to use Java's ___________method.
Class.forName();
Class.forName;
class.forname();
Class.Forname();
To open a connection, DriverManager._____________________() is to be used.
getConnection
getConnectivity
getManager
None of the above
___________ method returns the total number of columns in the ResultSet object.
getColumnCount()
getColumnCount
getColumnName()
getColumnName
_______________ method is used to create an object of the class ResultSetMetaData.
getMetaData()
getMetaData
Both a and b
None of the above
