This is a simple console-based library management system built with Java and MariaDB. It allows for basic database operations to manage books, members, and book loans.
Book.java
: Java class for the Book entity.DatabaseManager.java
: Handles all database connection and CRUD (Create, Read, Update, Delete) operations.LibraryApp.java
: The main application class with the primary logic.Member.java
: Java class for the Member entity.library.sql
: SQL script to create the database schema and insert initial data.mariadb-java-client-3.1.4.jar
: The JDBC driver for connecting Java to MariaDB.config.properties
: Configuration file for storing database connection details.
To run this project locally, you need the following software installed on your system:
- Java Development Kit (JDK) 8 or higher
- MariaDB Server
- Maven or Gradle (recommended for dependency management) or the ability to manually manage the classpath.
First, clone this repository to your local machine using git:
git clone https://github.com/akash2003git/library-management-java.git
cd library-management-java
You'll need to create the database and tables using the provided SQL script.
-
Log in to your MariaDB server.
sudo mariadb -u root -p
-
Run the
library.sql
script to create the database and tables.SOURCE /path/to/your/project/folder/library.sql;
Create a config.properties
file in the root directory of the project and add your database credentials.
db.url=jdbc:mariadb://localhost:3306/library_db
db.user=root
db.password=your_strong_password
Now, you can compile and run the Java application from your terminal.
-
Compile the Java files:
javac -cp .:mariadb-java-client-3.1.4.jar *.java
-
Run the main application:
java -cp .:mariadb-java-client-3.1.4.jar LibraryApp
- Add more advanced features like user authentication.
- Implement a command-line interface (CLI) for better user interaction.
- Use
PreparedStatement
to prevent SQL injection attacks. - Integrate with a web framework like Spring Boot to create a web-based application.