โ† All 1Z0-819 Flashcard Decks

JDBC Flashcards

7 cards from real 1Z0-819 practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 7 JDBC flashcards as text
  1. Which `ResultSet` method retrieves the value of a column as a `java.sql.Timestamp`?

    Answer: getTimestamp(columnLabel)

    `ResultSet.getTimestamp(columnLabel)` retrieves a column value as a `java.sql.Timestamp`, which represents both date and time with nanosecond precision.

  2. What does `ResultSet.wasNull()` return after calling a getter like `getInt()`?

    Answer: true if the last column read contained a SQL NULL value

    `wasNull()` returns `true` if the last column value read via any getter was SQL NULL, since primitive getters like `getInt()` return 0 for NULL and you need this method to distinguish.

  3. Which approach correctly loads a JDBC driver in Java 11 without explicitly calling `Class.forName()`?

    Answer: The ServiceLoader mechanism automatically discovers drivers on the classpath via META-INF/services

    Since JDBC 4.0 (Java 6+), drivers on the classpath are auto-loaded via the `ServiceLoader` mechanism using `META-INF/services/java.sql.Driver`, eliminating the need for `Class.forName()`.

  4. Which method on `CallableStatement` registers an OUT parameter before executing a stored procedure?

    Answer: registerOutParameter(index, sqlType)

    `CallableStatement.registerOutParameter(index, sqlType)` must be called before execution to tell JDBC the type of each OUT parameter to be retrieved afterward.

  5. What SQL syntax is used in JDBC to call a stored procedure with one IN and one OUT parameter?

    Answer: "{call myProc(?, ?)}"

    JDBC uses the escape syntax `{call procedureName(?, ?)}` to call stored procedures in a portable, database-independent way.

  6. Which `Connection` transaction isolation level offers the strongest consistency guarantee, preventing dirty reads, non-repeatable reads, and phantom reads?

    Answer: TRANSACTION_SERIALIZABLE

    `TRANSACTION_SERIALIZABLE` is the highest isolation level, ensuring full serializability by preventing dirty reads, non-repeatable reads, and phantom reads.

  7. What is returned by `PreparedStatement.execute()` when the SQL is a SELECT query?

    Answer: true, indicating a ResultSet is available via getResultSet()

    `execute()` returns `true` when the first result is a `ResultSet` (e.g., for SELECT), after which you call `getResultSet()` to retrieve it.