What is the difference between 'dirty read' and 'non-repeatable read' in the context of transaction isolation levels?

  • Dirty read: Reading committed data
  • Dirty read: Reading uncommitted data
  • Non-repeatable read: Reading committed data
  • Non-repeatable read: Reading uncommitted data
In the context of transaction isolation levels, a 'dirty read' occurs when a transaction reads uncommitted data from another transaction, while a 'non-repeatable read' happens when a transaction reads data committed by another transaction but the data changes before the first transaction completes. Understanding these concepts is crucial in managing data consistency and isolation in concurrent transactions.

How do distributed transactions differ from local transactions?

  • Concurrency and Durability
  • Consistency and Recovery
  • Isolation and Atomicity
  • Scope and Participants
Distributed transactions involve multiple participants and a wider scope, whereas local transactions are limited to a single resource or database.

What is two-phase commit protocol in the context of transaction management?

  • A protocol for authentication
  • A protocol for coordination
  • A protocol for data retrieval
  • A protocol for voting
The two-phase commit protocol is a coordination protocol involving a voting phase and a decision phase to ensure distributed transaction consistency.

The isolation level that allows neither dirty reads nor non-repeatable reads is called _________.

  • Read Committed
  • Read Uncommitted
  • Repeatable Read
  • Serializable
The Serializable isolation level ensures neither dirty reads nor non-repeatable reads, providing the highest level of isolation.

The concept of ________ allows multiple users to make changes to the database without affecting each other.

  • Concurrency Control
  • Consistency Management
  • Isolation
  • Transaction Control
The concept of Concurrency Control allows multiple users to make changes to the database concurrently without affecting each other, ensuring data integrity and consistency.

In a distributed system, when two databases must be updated as part of a single transaction, which transaction management technique is most appropriate?

  • Isolation (I)
  • Optimistic Concurrency Control (OCC)
  • Pessimistic Concurrency Control (PCC)
  • Two-Phase Commit (2PC)
The Two-Phase Commit (2PC) is most appropriate for managing transactions in a distributed system involving updates to multiple databases, ensuring atomicity and consistency across the distributed environment.

How do you differentiate between checked and unchecked SQL exceptions?

  • Checked exceptions are SQLExceptions
  • Checked exceptions are caught at compile-time
  • Unchecked exceptions are SQLExceptions
  • Unchecked exceptions are caught at compile-time
Checked SQL exceptions are those derived from SQLException, and they must be either caught or declared to be thrown. Unchecked SQL exceptions are those that extend RuntimeException.

What is the best practice for handling SQL exceptions in a multi-tier application?

  • Catch and log the exception at the point of occurrence
  • Convert the SQL exception to a custom exception
  • Handle the exception and continue processing
  • Propagate the exception to the upper tiers
The best practice is to propagate the SQL exception to the upper tiers to allow centralized handling and logging, providing a clear separation of concerns in a multi-tier application.

In JDBC, how can you ensure that all resources are freed, even if an SQL exception occurs?

  • Close resources in the catch block
  • Implement a custom resource management mechanism
  • Resources are automatically freed in JDBC
  • Use the finally block to close resources
Using the finally block ensures that resources (like connections, statements, result sets) are closed, even if an SQL exception occurs, promoting proper resource management and avoiding leaks.

In JDBC, the __________ exception is thrown when there is a problem with the SQL syntax.

  • DBException
  • SQLException
  • SQLSyntaxException
  • SyntaxException
In JDBC, the SQLException is thrown when there is a problem with the SQL syntax.