Your College Q&A Platform supports multiple database configurations:
Configuration: application.properties
- Type: In-memory (data lost on restart)
- URL:
jdbc:h2:mem:testdb - Username:
sa - Password: (empty)
Access H2 Console:
- Start application:
mvn spring-boot:run - Open browser:
http://localhost:8081/h2-console - Connection settings:
- JDBC URL:
jdbc:h2:mem:testdb - User Name:
sa - Password: (leave empty)
- JDBC URL:
- Click "Connect"
Configuration: application-h2-file.properties
- Type: File-based (data persists)
- URL:
jdbc:h2:file:./data/college_qa_db - Username:
sa - Password:
admin123
To Use:
cd backend
mvn spring-boot:run -Dspring.profiles.active=h2-fileAccess H2 Console:
- URL:
http://localhost:8081/h2-console - JDBC URL:
jdbc:h2:file:./data/college_qa_db - User Name:
sa - Password:
admin123
Configuration: application-postgresql.properties
- URL:
jdbc:postgresql://localhost:5432/college_qa_db - Username:
postgres - Password:
password
Setup Steps:
- Install PostgreSQL
- Create database:
CREATE DATABASE college_qa_db;
- Run application:
mvn spring-boot:run -Dspring.profiles.active=postgresql
Configuration: application-mysql.properties
- URL:
jdbc:mysql://localhost:3306/college_qa_db - Username:
root - Password:
password
Setup Steps:
- Install MySQL
- Create database:
CREATE DATABASE college_qa_db;
- Run application:
mvn spring-boot:run -Dspring.profiles.active=mysql
The application creates these tables automatically:
id(Primary Key)title(VARCHAR 200)content(VARCHAR 2000)student_name(VARCHAR 100)student_email(VARCHAR 100)category(VARCHAR 50)priority(ENUM: LOW, MEDIUM, HIGH, URGENT)status(ENUM: PENDING, IN_PROGRESS, ANSWERED, CLOSED)created_at(TIMESTAMP)updated_at(TIMESTAMP)
id(Primary Key)content(VARCHAR 3000)expert_name(VARCHAR 100)expert_email(VARCHAR 100)expert_title(VARCHAR 100)is_verified(BOOLEAN)helpful_count(INTEGER)question_id(Foreign Key)created_at(TIMESTAMP)updated_at(TIMESTAMP)
cd backend
mvn spring-boot:runcd backend
mvn spring-boot:run -Dspring.profiles.active=h2-filecd backend
mvn spring-boot:run -Dspring.profiles.active=postgresqlcd backend
mvn spring-boot:run -Dspring.profiles.active=mysql- H2 Console:
http://localhost:8081/h2-console - API Base URL:
http://localhost:8081/api - Frontend:
http://localhost:3000
You can insert sample data through:
- H2 Console (SQL commands)
- API endpoints (POST requests)
- Frontend application
- Port 8081 in use: Change
server.portin properties file - Database connection failed: Check database server is running
- Tables not created: Check
spring.jpa.hibernate.ddl-autosetting - CORS errors: Verify frontend URL in CORS configuration