Introduction to Java Programming, Sixth Edition, Y. Daniel Liang

Chapter 33 Advanced Java Database Programming


Section 33.3 Batch Processing
1  To add the SQL statement "insert into T values (100, 'Smith')" into the batch into a Statement stmt, use

A. stmt.add("insert into T values (100, 'Smith')");
B. stmt.add('insert into T values (100, 'Smith')');
C. stmt.addBatch("insert into T values (100, 'Smith')");
D. stmt.addBatch('insert into T values (100, 'Smith')');

2  Invoking executeBatch() returns ________.

A. an int value indicating how many SQL statements in the batch have been executed succefully.
B. a ResultSet
C. an array of counts, each of which counts the number of the rows affected by the SQL command.
D. an int value indicating how many rows are effected by the batch execution.

Section 33.4 Scrollable and Updateable Result Set
3  To obtain a scrollable or updateable result set, you must first create a statement using the following syntax:

A. Statement statement = connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
B. Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
C. Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
D. Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

4  In a scrollable and updateable result set, you can use ___________ methods on a result set.

A. first()
B. last()
C. insertRow()
D. deleteRow()
E. updateRow()

Section 33.5 RowSet, JdbcRowSet, and CachedRowSet
5  RowSet is an extension of _______.

A. Connection
B. Statement
C. ResultSet
D. CLOB

6  You can use a RowSet to __________.

A. set a database URL
B. set a database username
C. set a database password
D. set a SQL query statement

7  You may create a RowSet using __________.

A. new RowSet()
B. new JdbcRowSet()
C. new CachedRowSet()
D. new JdbcRowSetImpl()
E. new CachedRowSetImpl()

8  To move the cursor to the 2nd row in a RowSet using _________.

A. next(2)
B. first()
C. next()
D. absolute(2)
E. last()

9  To update a String column in a RowSet using _________.

A. updateString("newValue")
B. updateString("columnName", "newValue")
C. updateString("newValue", "columnName")
D. updateObject("newValue", "columnName")

10  To commit the changes in a CachedRowSet, use ___________.

A. commint()
B. acceptChanges()
C. acceptUpdates()
D. refresh()

Section 33.6 Storing and Retrieving Images in JDBC
11  You can store images in a database using data type _______.

A. varchar2
B. varchar
C. BLOB
D. CLOB

12  You can store large text in a database using data type _______.

A. varchar2
B. varchar
C. BLOB
D. CLOB

13  You can store large text in a database using data type _______.

A. varchar2
B. varchar
C. BLOB
D. CLOB

14  To get binary data from a column, use _____________ in Statement.

A. getBlob()
B. getBinaryStream()
C. getBinaryData()
D. getBinaryData()

15  To set binary data to a column, use _____________ in Statement.
A. setBlob()
B. setBinaryStream()
C. setBinaryData()
D. setBinaryData()