nerdexam
Oracle

1Z0-804 · Question #69

Given the code fragment: Assume that the SQL queries return records. What is the result of compiling and executing this code fragment?

The correct answer is C. The program prints Error. !!! The given Code prints Error -- the second query clears the ResultSet !? ErrorMessage: Operation notallowed after ResultSet closed It would print A, if second Query i set to rs = stmt.executeQuery("SELECT ID FROM Customer"); It would print B, if Line *** is missing. // The…

Building Database Applications with JDBC

Question

Given the code fragment:

Assume that the SQL queries return records. What is the result of compiling and executing this code fragment?

Exhibit

1Z0-804 question #69 exhibit

Options

  • AThe program prints employee IDs
  • BThe program prints customer IDs
  • CThe program prints Error
  • DCompilation fails on line ***

How the community answered

(68 responses)
  • A
    12% (8)
  • B
    3% (2)
  • C
    79% (54)
  • D
    6% (4)

Explanation

!!! The given Code prints Error -- the second query clears the ResultSet !? ErrorMessage: Operation notallowed after ResultSet closed It would print A, if second Query i set to rs = stmt.executeQuery("SELECT ID FROM Customer"); It would print B, if Line *** is missing. // The program compiles and runs fine. Both executeQuery statements will run. The first executeQuery statement (ResultSet rs = stmt.executeQuery(query);) will set the rs Resultset. It will be used in the while loop. EmployIDswill be printed. Executes the given SQL statement, which returns a single ResultSet object. Parameters:sql - an SQL statement to be sent to the database, typically a static SQL SELECT statement Returns:a ResultSet object that contains the data produced by the given query; never null

Topics

#Statement#ResultSet#multiple queries#JDBC

Community Discussion

No community discussion yet for this question.

Full 1Z0-804 Practice