In completing this assignment you MAY use/access the following resources:
- Examples and sample code found here:
https://josephus.hsutx.edu/classes/db/source/
- The SQL handout provided in class and also available here:
https://josephus.hsutx.edu/classes/db/source/sql.pdf
- A text editor (or VSCode) that provides syntax highlighting. You MAY
NOT USE an extensions to such editors/IDEs that produce code.
- The phpPgAdmin front end to your personal database (login is here:
https://csci.hsutx.edu/phpPgAdmin/
- Video instructions provided in Canvas as part of this course. You MAY
NOT USE any other video resources.
- Any handouts provided by the instructor as part of this course.
- Your own course notes
- Your instructor
- Discussions about the assignment with other students as long as you
never look at the code produced by another student and you never receive
instructions about solving the homework. That is, discussions need to
be about concepts and understanding the technologies and not about
how to solve the particular problem posed in this assignment.
You may NOT use/access:
- Resources not expressly listed above, including, but not limited to,
the following ...
- Source code not provided as part of this assignment. (Obviously, this
includes, but is not limited to, source code written by other students
whether current or in the past).
- Code-generating tools (of which ChatGPT is one example).
Failure to abide by these guidelines will result in a zero for the assignment
and the incident will be reported to the university provost as a violation of
the university academic integrity policy. A second incident of academic
dishonesty (whether from this course or another computer science course) will
result in an F in the course.
In this assignment you are given a substantial amount of code that you are not
allowed to modify. The driver simulates a significant number of concurrent
bank transactions. When the driver finishes there should be 7 newly created
accounts with the first account ending in $25.00 and the other accounts
ending with $1,600.00. There are three main steps to completing the program:
- Take time to thoroughly read and understand the code provided (there is
a lot of it!)
- In BankAccountDB.java write JDBC code to handle each of the
possible transactions (create, deposit, withdraw, transfer). In this
step do no worry about trying to deal with transactions and locking.
You will see that your code is “correct” but that it gives incorrect
results because of the overlapping database actions.
- Add the needed transaction/locking code to get correct results. Take
care to not do locking unless it is needed.
The starting code is provided in this repository:
https://tsergeant@bitbucket.org/tsergeant/db_bank_starter.git
These are the steps I would follow, but you can do things in whatever order you want:
- In bitbucket create a new repository by choosing the import option. Paste in
the URL above. Make sure you mark it as a private repository.
- In the bitbucket repository settings share the repository with terrys@gmail.com
- In your local workspace (on your computer) clone your copy of
the repository. Now you are ready to work on the code and your code will be turned
in automatically when you do your final push to bitbucket.
- Read and understand the README file in the repository.
- Open the index.html file in the javadoc directory with your
browser and get an overview of the project.
- Read the Transaction.java source code and then write a temporary driver
to play around with it. Once you feel comfortable with how it behaves you are
read to look at Driver.java.
- Execute the provided bank.sql file in your database to establish the
bank_account
table in a schema called bankdb.
- Read the Driver.java source code including the documentation to get a
sense of what the driver is doing.
- If you need a refresher on some of the concepts you'll need take a look at
the examples here: https://josephus.hsutx.edu/classes/db/source/transactions/
- One-by-one work on implementing each of the transactions in BankAccountDB.java.
You'll need to modify Driver.java to comment out parts that are not working
yet.
- Once the JDBC code is written and working, add transactions and locking to
get the expected results.
IMPORTANT: Each transaction should correctly set the result attribute in the
provided Transaction object. If funds are insufficient for a transfer then
no part of the transfer should take place. If funds are insufficient for a withdrawal
then the withdrawal should not take place. When creating a new account you should
use sequences/nextval to ensure each account gets a unique id number. DO NOT CHANGE
any of the provided source code (except, of course, for BankAccountDB.java).
Turn in your program by sharing with me your bitbucket (private) copy of the repository
and making sure your code is pushed by the due date.
Your program will be graded as follows:
Correct Create |
6 pts |
Correct Deposit |
3 pts |
Correct Withdraw |
3 pts |
Correct Transfer |
6 pts |
Correct/Efficient Locking |
12 pts |
Total |
30 pts |