What the second midterm will cover

For the second midterm exam I will give you one problem to solve which will involve constructing a JavaFX application that communicates with a database. You will have 70 minutes to complete the program.

Topics for the exam

For the GUI portion of the project you will be constructing an FXML application. As usual, your FXML application will have a controller class. That controller class will interact with a separte DAO class that you will write to handle the database interactions.

Beyond the basics of JavaFX, here is a list of database topics you should review in preparation for the exam.

Sample exam problem

Here is a sample problem for you to practice on. This is an actual exam problem from a previous iteration of CMSC 250.

In this problem you will construct a simple JavaFX application that acts as the front end for a simple electronic cash system. The system will allow the user to enter the account number they are transferring units from, the account number of the account they are transferring units to, and the number of units to transfer.

If the tranfer goes through successfully, the application will update the balances of the two accounts and make a record of the transaction in a transaction table.

Database for the problem

Start by creating a new schema in the MySQL with the name 'ecash'. Click this link to download an archive containing the schema data. Import this data into MySQL.

The ecash database contains two tables.

The accounts table records balances in user accounts.

ColumnTypeDescription
idINTid number of the account
balanceINTCurrent account balance

The transactions table records the details of transfers.

ColumnTypeDescription
idINTTransfer id (generated automatically)
amountINTUnits transferred
fromAcctINTAccount id of origin account
toAcctINTAccount id of destination account

User interface

Construct a JavaFX application that allows users to transfer units from one account to another. The user will enter the id number of the origin and destination accounts and the amount to transfer. Clicking the Transfer button initiates the transfer.

The application will update the database when the transfer goes through, adjusting the balances in the two accounts and adding a new row to the transactions table.

If the transfer is successful the application will display a message.

If the origin account does not have sufficient funds to make the transfer happen the application will display a message and not do the transfer.

Solution