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
What happens if you call `Connection.rollback()` when `autoCommit` is `true`?
Answer: It throws an SQLException
Calling `rollback()` when `autoCommit` is `true` throws an `SQLException` because there is no active transaction to roll back.
Which `DatabaseMetaData` method retrieves a `ResultSet` of all tables in the connected database?
Answer: getTables(catalog, schema, tableNamePattern, types)
`DatabaseMetaData.getTables(catalog, schemaPattern, tableNamePattern, types)` returns a ResultSet describing the tables available in the connected database.
Which `SavePoint` feature allows partial rollback within a transaction?
Answer: Connection.createSavepoint() marks a point you can roll back to without aborting the whole transaction
`Connection.setSavepoint()` marks an intermediate point in a transaction that you can roll back to with `rollback(savepoint)` while keeping earlier changes.
Which `ResultSet` concurrency constant allows updates to be made through the ResultSet object?
Answer: ResultSet.CONCUR_UPDATABLE
`ResultSet.CONCUR_UPDATABLE` allows the caller to update rows in the database directly through the ResultSet using update methods.
What is the purpose of `DataSource` compared to `DriverManager` in JDBC?
Answer: DataSource provides connection pooling and is the preferred enterprise approach
`DataSource` is the preferred way to obtain connections in enterprise applications because it supports connection pooling, improving performance and scalability.
Which JDBC isolation level prevents dirty reads but still allows non-repeatable reads?
Answer: TRANSACTION_READ_COMMITTED
`TRANSACTION_READ_COMMITTED` prevents dirty reads (reading uncommitted data) but allows non-repeatable reads since data can change between reads in the same transaction.
Which method on `Statement` adds a SQL command to a pending batch without executing it immediately?
Answer: addBatch(sql)
`Statement.addBatch(sql)` appends the SQL command to the current batch list; the batch is not sent to the database until `executeBatch()` is called.