|
Got Fabrikam, Wingtip, Hansom, Proseware
|
Question 1. Under JDBC, you can move the cursor within the resultset to a particular specified row using which of the following methods? A. absolute B. jump C. goto D. moveto E. nextset Answer: A Explanation: According to the online Java tutorial provided by Sun at java.sun.com: You can move the cursor to a particular row in a ResultSet object. The methods first, last, beforeFirst, and afterLast move the cursor to the position their names indicate. The method absolute will move the cursor to the row number indicated in the argument passed to it. If the number is positive, the cursor moves the given number from the beginning, so calling absolute(1. puts the cursor on the first row. If the number is negative, the cursor moves the given number from the end, so calling absolute(-1. puts the cursor on the last row. Question 2. You are the database specialist of your company. You are managing the in-house database systems. With JDBC, you want to make updates to a ResultSet object. To do so, what must you supply to the ResultSet object? A. CONCUR_UPDATABLE B. UPDATABLE C. CONCUR D. CONCUR_RESULT E. RESULT_UPDATABLE Answer: A Explanation: According to the online Java tutorial provided by Sun at java.sun.com: Before you can make updates to a ResultSet object, you need to create one that is updatable. In order to do this, you supply the ResultSet constant CONCUR_UPDATABLE to the createStatement method. The Statement object that is created will produce an updatable ResultSet object each time it executes a query. Question 3. Under JDBC, what object represents the DBMS that supplies you with all the company SALES data? A. DataSource B. FileSource C. DSN D. ResultSource E. DataOrigin Answer: A Explanation: According to the online Java tutorial provided by Sun at java.sun.com: A DataSource object represents a particular DBMS or some other data source, such as a file. If a company uses more than one data source, it will deploy a separate DataSource object for each of them. A DataSource object may be implemented in three different ways: A basic DataSource implementation-produces standard Connection objects that are not pooled or used in a distributed transaction A DataSource class that supports connection pooling-produces Connection objects that participate in connection pooling, that is, connections that can be recycled A DataSource class that supports distributed transactions-produces Connection objects that can be used in a distributed transaction, that is, a transaction that accesses two or more DBMS servers Question 4. In JDBC, what class allows the use of HTTP to talk to a Java servlet that provides data access? A. A CachedRowSet class B. A JDBCRowSet class C. A WebRowSet class D. A JavaSource class E. AHTTPRowSet class F. A JavaDb class Answer: C Explanation: According to the online Java tutorial provided by Sun at java.sun.com: Although anyone can implement a rowset, most implementations will probably be provided by vendors offering RowSet classes designed for fairly specific purposes. To make writing an implementation easier, the JavaTM Software division of Sun Microsystems, Inc., plans to provide reference implementations for three different styles of rowsets in the future. The following list of planned implementations gives you an idea of some of the possibilities. A CachedRowSet class-a disconnected rowset that caches its data in memory; not suitable for very large data sets, but an ideal way to provide thin Java clients, such as a Personal Digital Assistant (PD A. or Network Computer (NC., with tabular data A JDBCRowSet class-a connected rowset that serves mainly as a thin wrapper around a ResultSet object to make a JDBC driver look like a JavaBeans component A WebRowSet class-a connected rowset that uses the HTTP protocol internally to talk to a Java servlet that provides data access; used to make it possible for thin web clients to retrieve and possibly update a set of rows Question 5. To properly handle SQLException under JDBC, you must use: A. a try/catch block B. a Exception pointer C. the Err object D. the error table E. the master error dictionary Answer: A Explanation: According to the online Java tutorial provided by Sun at java.sun.com: Many of the methods in the java.sql package throw an SQLException , which requires a try/catch block like any other Exception. Its purpose is to describe database or driver errors (SQL syntax, for example.. In addition to the standard getMessage(. inherited from Throwable, SQLException has two methods which provide further information, a method to get (or chain. additional exceptions and a method to set an additional exception Question 6. Which of the following are the valid methods for handling SQL exceptions generated in JDBC (Choose all that apply.? A. getSQLState(. B. getErrorCode(. C. getNextException(. D. setNextException(. Answer: A, B, C, D Explanation: According to the online Java tutorial provided by Sun at java.sun.com: getSQLState(. returns an QLState identifier based on the X/Open SQL specification. Your DBMS manuals should list some of these or see Resources for information to find SQLStates. getErrorCode(. is provided to retrieve the vendor-specific error code. getNextException(. retrieves the next SQLException or null if there are no more. Many things can go wrong between your program and the database. This method allows tracking all problems that occur. setNextException(. allows the programmer to add an SQLException to the chain. Question 7. You are the database specialist of your company. You are managing the in-house database systems. In your JDBC application you want to provide warnings to users without terminating the operations. Which of the following classes may you use? A. SQLWarning B. SQLNotice C. SQLError D. SQLInform E. SQLWarns Answer: A Explanation: According to the online Java tutorial provided by Sun at java.sun.com: An SQLWarning is a subclass of SQLException, but is not thrown like other exceptions. The programmer must specifically ask for warnings. Connections, Statements, and ResultSets all have a getWarnings(. method that allows retrieval. There is also a clearWarnings(. method to avoid duplicate retrievals. The SQLWarning class itself only adds the methods getNextWarning(. And setNextWarning(.. An SQLWarning is very similar to traditional compiler warnings: something not exactly right occurred, but its effect was not severe enough to end processing. Whether it is important enough to investigate depends on the operation and context. Question 8. Under JDBC, which of the following are the responsibilities of the Connection object (Choose all that apply.? A. Creating Statement instances. B. Obtaining DatabaseMetadata objects. C. Controlling transactions D. Setting isolation levels Answer: A, B, C, D Explanation: According to the online Java tutorial provided by Sun at java.sun.com: The Connection itself is responsible for several areas including: Creating Statement, PreparedStatement, and CallableStatement (used with stored procedures. instances. Obtaining DatabaseMetadata objects. Controlling transactions via the commit(. and rollback(. methods. Setting the isolation level involved in transactions. Question 9. In JDBC, what function returns an int containing the affected row count for INSERT, UPDATE, or DELETE statements? A. executeUpdate(. B. execute(. C. Update(. D. runUpdate(. E. SQLUpdate(. Answer: A Explanation: According to the online Java tutorial provided by Sun at java.sun.com: executeUpdate(. returns an int containing the affected row count for INSERT, UPDATE, or DELETE statements, or zero for SQL statements that do not return anything, like DDL statements. Question 10. Mix and match question:SQL Type Java Method FLOAT INTEGER LONGVARBINARY LONGVARCHAR NUMERIC OTHER Java Method getDouble(. getInt(. getBytes(. getString(. getBigDecimal(. getObject(. Match the Java methods to the corresponding SQL data types: A. SQL Type Java Method FLOAT getDouble(. INTEGER getInt(. LONGVARBINARY getBytes(. LONGVARCHAR getString(. NUMERIC getBigDecimal(. OTHER getObject(. B. SQL Type Java Method LONGVARBINARY getDouble(. INTEGER getInt(. FLOAT getBytes(. LONGVARCHAR getString(. NUMERIC getBigDecimal(. OTHER getObject(. C. SQL Type Java Method NUMERIC getDouble(. INTEGER getInt(. LONGVARBINARY getBytes(. LONGVARCHAR getString(. FLOAT getBigDecimal(. OTHER getObject(. D. SQL Type Java Method FLOAT getDouble(. INTEGER getInt(. LONGVARCHAR getBytes(. LONGVARBINARY getString(. NUMERIC getBigDecimal(. OTHER getObject(. Answer: A Explanation: According to the online Java tutorial provided by Sun at java.sun.com: Memorize the list below:SQL Type Java Method BIGINT getLong(. BINARY getBytes(. BIT getBoolean(. CHAR getString(. DATE getDate(. DECIMAL getBigDecimal(. DOUBLE getDouble(. FLOAT getDouble(. INTEGER getInt(. LONGVARBINARY getBytes(. LONGVARCHAR getString(. NUMERIC getBigDecimal(. OTHER getObject(. REAL getFloat(. SMALLINT getShort(. TIME getTime(. TIMESTAMP getTimestamp(. TINYINT getByte(. VARBINARY getBytes(. VARCHAR getString(.
Copyright © 2004 CertsBraindumps.com Inc. All rights reserved.