1Z0-805 · Question #73
Given this code fragment: try { String query = "SELECT * FROM Item"; Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(query); ResultSetMetaData rsmd = rs.getMetaData(); int…
The correct answer is A. Compilation fails. There is no GetRowCount method in java.sql.ResultSetMetaData. The following line will not compile: int rowCount = rsmd.getRowCount();
Question
Given this code fragment:
try { String query = "SELECT * FROM Item"; Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(query); ResultSetMetaData rsmd = rs.getMetaData(); int rowCount = rsmd.getRowCount(); System.out.println ("Processing: " + rowCount + " rows."); while (rs.next()) { // Process each row } } catch (SQLException se) { System.out.println("Error"); } Assume that the SQL query returns records. What is the result?
Options
- ACompilation fails.
- BThe program prints Error
- CAn exception is thrown at runtime
- DThe statement at line 16 execute
How the community answered
(45 responses)- A71% (32)
- B4% (2)
- C7% (3)
- D18% (8)
Explanation
There is no GetRowCount method in java.sql.ResultSetMetaData. The following line will not compile: int rowCount = rsmd.getRowCount();
Topics
Community Discussion
No community discussion yet for this question.