https://github.com/programmersteve/javabankcli
A java cli application that connects to a postgresql database to persist data for users and accounts.
https://github.com/programmersteve/javabankcli
java postgresql
Last synced: 5 months ago
JSON representation
A java cli application that connects to a postgresql database to persist data for users and accounts.
- Host: GitHub
- URL: https://github.com/programmersteve/javabankcli
- Owner: ProgrammerSteve
- Created: 2024-07-12T05:09:13.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-15T04:51:51.000Z (over 1 year ago)
- Last Synced: 2025-03-29T10:44:37.849Z (10 months ago)
- Topics: java, postgresql
- Language: Java
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
### Setting up connection to postgresql database
- Navigate to directory: `src/main/resources`
- create a file called: `db.properties`
- Should follow the format:
```
jdbc.url=jdbc:postgresql://XXXXXXX/XXXXXXX
jdbc.username=XXXXXXX
jdbc.password=XXXXXXX
```
### Setting up tables on database
- There is a one-to-one relationship between two tables: `users`, `accounts`
```
CREATE TABLE IF NOT EXISTS users (
user_id SERIAL PRIMARY KEY,
username VARCHAR(50) UNIQUE,
password VARCHAR(50)
);
CREATE TABLE IF NOT EXISTS accounts (
account_id SERIAL PRIMARY KEY,
user_id INT UNIQUE,
balance DECIMAL(10, 2) CHECK (balance >= 0),
FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE
);
```
### If unauthenticated the CLI will look like:
```
Choose an action:
1:Login
2:Register
3:Exit
```
### If authenticated the CLI will look like:
```
Hello {NAME}, Choose an action:
1:ViewBalance
2:Withdraw
3:Deposit
4:Logout
5:Exit
```