Java Reference
In-Depth Information
Answers to Review Questions
1.
Okay, that's a trick question. It is commonly referred to as Java Database Connectivity,
but it officially does not stand for anything.
2.
Type 4 drivers are pure-Java drivers typically provided by the database vendor, so the
answer is d.
3.
Type 3 drivers work on different databases, so the answer is c.
4.
The question describes exactly how type 3 drivers work, so the answer is c again.
5.
A driver is loaded by having the JVM load its corresponding class. This is typically done
using the Class.forName() method.
6.
jdbc:odbc:contactsDSN.
7.
The result will be all columns from the rows in SomeTable whose someColumn data
contains the substring 'java' in any part of it.
8.
Simple statements of type Statement, prepared statements of type PreparedStatement,
and callable statements of type CallableStatement.
9.
A simple statement would probably work best when only executing the statement
once.
10.
A prepared statement is more efficient when used repeatedly because its SQL is pre-
compiled by the database. A stored procedure might also work well too.
11.
java.sql.Statement.
12.
java.sql.PreparedStatement.
13.
b makes the result set scrollable, and d makes it updatable.
14.
b is the likely choice, although a works for any SQL statement, and d actually works if
you add the statement to a batch. The only two that don't work are c, which is for SQL
statements that return a ResultSet, and the runSQL() method is one I made up.
15.
True. You must invoke next() on a ResultSet, even if it only contains one row.
16.
False. The next() method returns false if there is no next row.
17.
The cursor moves five rows ahead of its current position.
18.
True. Nonscrollable result sets can only be navigated forward.
19.
True. The data of the ResultSet object changes.
20.
False. The data in the database does not change. You need to invoke updateRow()
before any updates appear in the database.
21.
False. The first parameter has an index 1.
22.
b. createCall() is not a method in Connection, prepareStatement() is for prepared
statements, and createStatement() is for simple statements.
Search WWH ::




Custom Search