The Library Management System (LMS) is a Java-based application it is designed to manage library operations, including adding books, borrowing books, returning books, and managing user accounts. The system leverages a MySQL database to store information about books and users.
The project is organized into the following packages:
- DAOInterface: Contains interfaces for Data Access Objects (DAOs).
- DAOimplement: Contains implementations of the DAOs.
- database: Contains database connection configuration.
- enums: Contains enumerations used in the project.
- model: Contains model classes representing data entities.
-
BookDAO
- Methods:
addBook
,borrowBook
,returnBook
,findBookById
,findBookByTitle
,listBooks
,listBooksOfCategory
- Methods:
-
UserDAO
- Methods:
addUser
,getUserByUsername
,login
- Methods:
-
BookDAOImpl
- Implements
BookDAO
interface with methods for adding, borrowing, returning books, and querying the database for book details.
- Implements
-
UserDaoImpl
- Implements
UserDAO
interface with methods for adding users, retrieving user details, and user authentication.
- Implements
- Database
- Manages the connection to the MySQL database, ensuring a singleton connection instance is used throughout the application.
- UserRole
- Enumeration for user roles, supporting
admin
anduser
roles.
- Enumeration for user roles, supporting
-
Book
- Represents a book entity with properties like
id
,title
,authorId
,category
, anduserId
.
- Represents a book entity with properties like
-
User
- Represents a user entity with properties like
id
,username
,password
, anduserRole
.
- Represents a user entity with properties like
Ensure your MySQL server is running and create a database named LibraryManagementSystem
. Update the url
, userName
, and password
fields in the Database
class to match your MySQL server configuration.
- Set Up Database: Ensure you have a MySQL database named
LibraryManagementSystem
. - Dependencies: Make sure you have the necessary JDBC driver for MySQL in your classpath.
- Compile and Run: Compile the Java files and run the application using your preferred method (e.g., IDE like IntelliJ IDEA or Eclipse, or via the command line).
The application uses Java's built-in logging system to log various events and errors. This helps in understanding the flow of the application and debugging issues.
Each method in the DAO implementations includes error handling using try-catch blocks. SQLException
instances are caught and logged to provide detailed error messages.