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

An overview of jdbc, a java api for connecting to databases and executing sql statements. It also covers the concept of database transactions, including their properties (acid) and potential issues in multi-user databases. Examples of lost updates and uncommitted changes are given, as well as solutions using pessimistic and optimistic locking and database logs.

Typology: Slides

2020/2021

Uploaded on 06/11/2021

loveu
loveu 🇺🇸

4.4

(21)

292 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

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