Skip to content

Latest commit

 

History

History
126 lines (85 loc) · 2.89 KB

File metadata and controls

126 lines (85 loc) · 2.89 KB

Database Setup Guide for PawsConnect Hub

This document provides the complete database setup process for local development and testing.

Purpose

Use this guide to:

  1. Install and verify MySQL.
  2. Create the project database.
  3. Import the schema from src/main/resources/schema.sql.
  4. Configure src/main/java/com/pawsconnect/util/DBConnection.java.
  5. Validate that the backend can connect successfully.

Prerequisites

1. Verify MySQL Installation

Connect to MySQL and run:

SELECT VERSION();

Expected: a MySQL 8.x version string.

2. Create Database

CREATE DATABASE IF NOT EXISTS pawsconnect;
USE pawsconnect;

3. Import Schema

From the repository root, use one of the following options.

Option A: Import from inside MySQL shell

USE pawsconnect;
SOURCE src/main/resources/schema.sql;

Option B: Import directly from terminal

Windows PowerShell:

mysql -u root -p pawsconnect < src/main/resources/schema.sql

Linux/Arch:

mysql -u root -p pawsconnect < src/main/resources/schema.sql

4. Verify Tables

USE pawsconnect;
SHOW TABLES;

Expected tables:

  • users
  • posts
  • marketplace_items

Optional row-count check:

SELECT COUNT(*) FROM users;
SELECT COUNT(*) FROM posts;
SELECT COUNT(*) FROM marketplace_items;

5. Configure Application DB Credentials

Open src/main/java/com/pawsconnect/util/DBConnection.java and set your local values:

private static final String URL = "jdbc:mysql://localhost:3306/pawsconnect?useSSL=false&serverTimezone=UTC";
private static final String USER = "root";
private static final String PASSWORD = "your_mysql_password";

Important:

  • Repository keeps password blank intentionally.
  • Never commit real credentials.

6. Connection Validation

After configuring credentials:

  1. Build project from repository root:
mvn clean package
  1. Run/deploy the app and open session endpoint:

If DB connectivity is correct, authentication and session operations should work after login.

Common Issues and Fixes

  • Access denied for MySQL user:
    • Verify username/password and user permissions.
  • Unknown database pawsconnect:
    • Re-run database creation commands.
  • Table not found:
    • Re-import schema file.
  • Communications link failure:
    • Confirm MySQL service is running and port 3306 is reachable.
  • Time zone warnings:
    • Keep serverTimezone=UTC in the JDBC URL.