🏧 A cash machine with a real ledger — a Java Swing ATM where every withdrawal, deposit and transfer is written to MySQL, not held in memory
ATM Simulator reproduces the flow of a cash machine: insert a card, enter a PIN, check the balance, withdraw, deposit, pay a bill, review the transaction history. The state lives in MySQL — cards, balances and history are three tables — so closing the application and reopening it finds the account exactly where it was left.
It was built for an object-oriented programming course, which is why the window classes, the table model and the database connector are deliberately separate rather than folded into one file.
- State in the database, not in the process —
karty,stan_kontaandtablehistoryhold the cards, the balances and every operation. Restarting the application changes nothing about the accounts. - A PIN gate with card selection — cards are chosen from a list and unlocked with a PIN before any window that touches money will open.
- Four operations, each its own window — balance, withdrawal, deposit and bill payment are separate classes, so a change to one cannot break another.
- History as a table, backed by a model —
MyTableModelfeeds the history window from the database rather than from a formatted string, so sorting and column widths behave. - A random-password generator —
MainRandomPasswordproduces PINs, kept separate from the flow that uses them. - A class diagram in the repository —
Diagram.pumlis the source,Diagram.pngthe render, so the structure can be read before the code is. - The full dataset ships with it —
database/holds both SQL dumps and CSV exports of all three tables.
| The main screen | Card PIN entry |
|---|---|
![]() |
![]() |
| Balance | Withdrawal |
|---|---|
![]() |
![]() |
| Bill payment | Transaction history |
|---|---|
![]() |
![]() |
| Table | What it holds |
|---|---|
karty |
Cards and their PINs. |
stan_konta |
The balance behind each card. |
tablehistory |
Every operation: type, amount, timestamp. |
The connection is configured in DatabaseConnector.java:
private static final String DATABASE_URL = "jdbc:mysql://localhost:3306/atm";| Technology | Role |
|---|---|
| Java | Application language. |
| Swing | Windows, dialogs and tables. |
| IntelliJ GUI Designer | .form files beside each window class. |
| JDBC | The MySQL connection. |
| MySQL / MariaDB | Cards, balances and history. |
| PlantUML | The class diagram. |
- JDK 17 or newer
- MySQL or MariaDB
- The MySQL JDBC driver on the classpath
git clone https://github.com/dawidolko/ATM-System-Java-Swing.git
cd ATM-System-Java-Swingmysql -u root -p -e "CREATE DATABASE atm;"
mysql -u root -p atm < database/karty.sql
mysql -u root -p atm < database/stan_konta.sql
mysql -u root -p atm < database/tablehistory.sqlEdit public/src/DatabaseConnector.java if your credentials differ from root with an empty password.
Open the project in IntelliJ IDEA (the .iml and .form files are part of it) and run Main. From the command line:
javac -cp mysql-connector-java.jar -d out public/src/*.java
java -cp out:mysql-connector-java.jar MainATM-System-Java-Swing/
├── public/src/
│ ├── Main.java # entry point
│ ├── MenuWindow.java/.form # card selection
│ ├── PinWindow.java/.form # PIN gate
│ ├── Dashboard.java/.form # operation menu
│ ├── BalanceWindow.java/.form # balance
│ ├── PaycheckWindow.java/.form# deposit
│ ├── PaymentWindows.java/.form# withdrawal and bill payment
│ ├── HistoryWindow.java/.form # transaction history
│ ├── MyTableModel.java # table model behind the history
│ ├── CardItem.java # one card in the list
│ ├── DatabaseConnector.java # the JDBC connection
│ ├── MainRandomPassword.java # PIN generator
│ └── Diagram.puml / .png # class diagram
├── database/ # SQL dumps and CSV exports of all three tables
└── docs/ # course documentation
A Polish version of this document is in README_POLISH.md.
MIT © Dawid Olko





