nerdexam
Oracle

1Z0-819 · Question #48

Assume db is a DataSource and the EMP table is defined appropriately. try (Connection conn = ds.getConnection(); PreparedStatement ps = conn.prepareStatement("INSERT INTO EMP VALUES(?, ?, ?)")) {…

The correct answer is C. Inserts one row (101, 'SMITH', 'HR'). See the full explanation below for the reasoning.

Question

Assume db is a DataSource and the EMP table is defined appropriately. try (Connection conn = ds.getConnection(); PreparedStatement ps = conn.prepareStatement("INSERT INTO EMP VALUES(?, ?, ?)")) { ps.setObject(1, 101, JDBCType.INTEGER); ps.setObject(2, "SMITH", JDBCType.VARCHAR); ps.setObject(3, "HR", JDBCType.VARCHAR); ps.executeUpdat e(); ps.setint(1, 102); ps.setString(2, "JONES"); ps.executeUpdate(); } What does executing this code fragment do?

Options

  • AInserts two rows (101, 'SMITH', 'HR') and (102, 'JONES', NULL)
  • BInserts two rows (101, 'SMITH', 'HR') and (102, 'JONES', 'HR')
  • CInserts one row (101, 'SMITH', 'HR')
  • DThrows a SQL Exception

How the community answered

(29 responses)
  • A
    7% (2)
  • B
    3% (1)
  • C
    79% (23)
  • D
    10% (3)

Community Discussion

No community discussion yet for this question.

Full 1Z0-819 Practice