Java Fintq II
Java Fintq II
a Java program that connects to a MySQL database using JDBC and demonstrates the
use of Savepoints with multiple tables. Create two tables, accounts and
transactions. The accounts table should have the columns: account_id (INT),
account_name (VARCHAR), and balance (FLOAT). The transactions table should have the
columns: transaction_id (INT), account_id (INT), amount (FLOAT), and
transaction_type (VARCHAR). Perform multiple inserts into these tables, using
Savepoints to manage the transaction. Roll back to a Savepoint if an error occurs
during one of the inserts.
_______________________________________________________________________
Tasks:
program that connects to a MySQL database using JDBC, updates records in a table
named products, and demonstrates the use of Savepoints. The products table should
have the following columns: product_id (INT), name (VARCHAR), price (FLOAT), and
stock (INT). Ensure the program loads the JDBC driver, establishes a connection,
and handles exceptions appropriately. Use Savepoints to manage the transaction,
updating the price and stock of multiple products. Roll back to a Savepoint if an
error occurs during the update of one of the products.
Tasks:
Write a Java program that connects to a MySQL database using JDBC, creates a table
named books, and deletes a record from it. The table books should have the
following columns: book_id (INT), title (VARCHAR), author (VARCHAR), and price
(FLOAT). Ensure the program loads the JDBC driver, establishes a connection, and
handles exceptions appropriately. Use a prepared statement to delete the book with
book_id = 2.