Docsity

JDBC and Database Transactions: Atomicity, Consistency, Isolation, and Durability, Slides of Data Structures and Algorithms

Toggle sidebar
bg1
1.204 Lecture 4
JDBC
Code examples from JDBC API Tutorial and Reference
JDBC API
โ€ขPackage (library) of classes and methods to connect from a
Java application to DBMS execute SQL statements and
Java application to DBMS
,
execute SQL statements and
retrieve results
โ€“SQL syntax primarily based on SQL-92 standard
โ€“Standard set of error codes
โ€“Standard way to connect and log on to DBMS
โ€“Standard representation of data types
โ€“Standard methods for data type conversions
โ€“Standard methods to send SQL queries and receive result sets
โ€“
JDBC has level 1-4 functionality to deal with simple and
sophisticated interfaces.
โ€“It can interface to files and other data sources as well
1
pf3

Partial preview of the text

Download JDBC and Database Transactions: Atomicity, Consistency, Isolation, and Durability and more Slides Data Structures and Algorithms in PDF only on Docsity!

1.204 Lecture 4

JDBC

Code examples from JDBC API Tutorial and Reference

JDBC API

  • Package (library) of classes and methods to connect from a

Java application to DBMS execute SQL statements andJava application to DBMS, execute SQL statements and

retrieve results

  • SQL syntax primarily based on SQL-92 standard
  • Standard set of error codes
  • Standard way to connect and log on to DBMS
  • Standard representation of data types
  • Standard methods for data type conversions
  • Standard methods to send SQL queries and receive result sets
  • JDBC has level 1-4 functionality to deal with simple and sophisticated interfaces.
  • It can interface to files and other data sources as well

Transactions

  • Group of operations often must be treated as atomic unit - Start transaction - Insert OrderHeader - While more OrderDetail (line items) exist: - Select Part - Update Part inventory - Insert OrderDetail row - Commit transaction if everything succeeds - Roll back transaction if any error occurs: - In Order Header - In OrderDetail - Server crashes - Disk crashes - Network dies - Etc.

Transaction properties (ACID)

  • Atomicityy. Either all of transactions are executed or all are

rolled back

  • Account transfer debit and credit both succeed or fail
  • Consistency. Only legal states can exist
  • If order detail cannot be written, order header is rolled back
  • Isolation. Results not seen by other transactions until the

transaction is complete

  • Account transfer debit and credit either both seen or neither is seenseen
  • Durability. Data is persistent even if hardware or software

crashes: What is written on the disk is correct

  • Account balance is maintained