Skip to content

Commit 2b33be0

Browse files
Update README.md
1 parent 6de0539 commit 2b33be0

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,54 @@ CREATE TABLE MoveHistory (...);
4949

5050
---
5151

52+
# ♟️ Java Chess Game with GUI & MySQL Integration
53+
54+
This is a complete Chess game implemented in Java using Swing for the GUI and JDBC for connecting to a MySQL database. The game follows standard chess rules including legal move validation, check, checkmate, castling, and en passant. Move history can be persisted using a MySQL database.
55+
56+
---
57+
58+
## 📁 Project Structure
59+
60+
JavaChess-main/
61+
├── src/
62+
│ ├── com/chess/database/DatabaseConnection.java
63+
│ ├── com/chess/model/MoveRecord.java
64+
│ ├── com/chess/dao/MoveHistoryDAO.java
65+
│ └── com/chess/GUI/GameHistoryPanel.java
66+
├── Chess pieces/ # Image assets
67+
├── JChess.java # Main game entry point
68+
└── README.md # This file
69+
70+
swift
71+
Copy
72+
Edit
73+
74+
---
75+
76+
## ✅ 5. JDBC Implementation (3 Marks)
77+
78+
We've successfully implemented JDBC to enable interaction between our Java Chess game and a MySQL database.
79+
80+
- A dedicated `DatabaseConnection.java` class was created to handle the database connection logic.
81+
- JDBC is used to connect the Java application to a MySQL database (`chessdb`).
82+
- This connection will support storing and retrieving move history or other game-related data in future extensions.
83+
84+
### 📄 `DatabaseConnection.java` Highlights
85+
86+
```java
87+
package com.chess.database;
88+
89+
import java.sql.Connection;
90+
import java.sql.DriverManager;
91+
import java.sql.SQLException;
92+
93+
public class DatabaseConnection {
94+
private static final String URL = "jdbc:mysql://localhost:3306/chessdb";
95+
private static final String USER = "root";
96+
private static final String PASSWORD = "yourpassword";
97+
98+
public static Connection getConnection() throws SQLException {
99+
return DriverManager.getConnection(URL, USER, PASSWORD);
100+
}
101+
}
52102

0 commit comments

Comments
 (0)