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

Chapter 38 Advanced Java Database Programming


Section 38.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 successfully.
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 38.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 38.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, use _________.

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

9  To update a String column in a RowSet, use _________.

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 38.6 RowSetTableModel
11  For a JTable to be synchronized with a JDBC RowSet, you may create a table model with the following features:

A. The model should extend AbstractTableModel and implement getRowCount(), getColumnCount(), and getValueAt(int row, int column).
B. The model should implement RowSetListener and the methods rowSetChanged(RowSetEvent e), rowChanged(RowSetEvent e), cursorMoved(RowSetEvent e).
C. You should invoke fireTableStructureChanged() method from rowSetChanged(RowSetEvent e) and rowChanged(RowSetEvent e) to synchronize changes in the RowSet with the the JTable

12  The index of row and column in JTable is 0-based. The index of row and column in RowSet is 1-based.

A. true
B. false

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

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

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

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

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

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

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

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

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