Coders Packet

Hostel Management System in Java using JDBC Connectivity

By K SYAM PRASAD

Java-based Hostel Management System simplifies admissions, billing & student data. User-friendly interface with MySQL integration.

Certainly! Let's go through the code in detail and explain each part:

PAGE - 1: [Login_Page.java]

Detail Code : 

  1. Importing libraries: The required Java libraries are imported, including those for GUI components and database connectivity.
  2. Login_Page’ class: This is the main class that represents the login page of the Hostel Management System.
  3. main’ method: The ‘main’ method is the entry point of the application. It creates an instance of ‘Login_Page’ and displays the login frame.
  4. initialize’ method: This method sets up the login frame and its components.
  5. JFrame frame’: A JFrame is created to display the login interface.
  6. Panels and Labels: Two panels are created to organize the components on the frame. Labels are used to display text, such as "HOSTEL OWNER," "OWNER ID," and "PASSWORD."
  7. JTextField id’: This JTextField allows the user to input the owner ID.
  8. JPasswordField pass’: This JPasswordField allows the user to input the password securely (characters are displayed as dots).
  9. JButton btnLogin’: This JButton is used for the login action. When clicked, the entered credentials are validated, and appropriate messages are displayed based on the input.
  10. ActionListener’: The login button has an ActionListener attached to it. When the button is clicked, the actionPerformed method is called. In this method, the owner ID and password are retrieved from the respective fields.
  11. Login Validation: The code checks if the owner ID and password are correct (in this case, the ID is "admin" and the password is "password"). If the credentials match, a successful login message is shown, and the main menu frame (‘Menu’) is displayed. If the credentials are incorrect or empty, appropriate error messages are shown.
  12. JLabel msg’: This JLabel is used to display various messages like "Login Successful," "Please Enter Login Details," "Enter admin ID," and "Incorrect Password" based on the input validation.

Overall, this code sets up a simple login page for the Hostel Management System, and upon successful login, it will navigate to the main menu of the system. However, it’s important to note that this code is just a part of the entire Hostel Management System and additional functionality and classes would be needed to create a complete system.

-------------------------------------

Before Login -> Application

Note : 

       Owner ID  : admin

       Password  : password

After Login -> Application [PAGE-2]

Incorrect Login credentials -> Application

Attempting to log in without providing login credentials will result in an authentication error, as the system requires valid credentials for successful login.

-------------------------------------

PAGE - 2: [Menu.java]

Detail Code : 

  1. load_table() method: This method is responsible for fetching data from the database and populating the JTable in the GUI with the retrieved data. It connects to the MySQL database using JDBC, executes a query to retrieve data from the "details" table, and then uses the DbUtils library to convert the ResultSet into a TableModel that can be displayed in the JTable.
  2. JComboBoxes’: The code adds three JComboBox components to the GUI. These combo boxes allow the user to select the number of months, room number, and payment amount while adding a new admission record. The selected values are stored in ‘comM’, ‘comRoom’, and ‘comPaytm’ variables, respectively, which are used when adding a new admission record.
  3. btnAdd’ ActionListener: When the "ADD" button is clicked, this ActionListener is triggered. It reads the input data from the JTextField components, validates them, and then inserts the admission record into the MySQL database. Before inserting, it also checks if the Aadhar number already exists in the database. If it does, it displays a message saying "Already Record found." Otherwise, it adds the new admission record to the "details" table and shows the message "=> Record Added <=." After successfully adding the record, the ‘load_table()’ method is called to update the JTable with the latest data.
  4. The "DELETE" button allows the hostel owner to remove a student's admission record from the database by executing a DELETE query based on the entered serial number (sNo) and refreshes the displayed table after successful deletion.
  5. JTable’ and JScrollPane: The ‘JTable table’ and ‘JScrollPane scrollPane’ are used to display the admission details fetched from the database. The JTable is populated using the ‘load_table()’ method. The user can see all the admission records in this table.
  6. comboBox’ ActionListener: This ActionListener is triggered when the user selects the number of months from the "MONTHS" JComboBox. The selected value is stored in the ‘comM’ variable.
  7. comboBox_1’ ActionListener: Similar to the previous ActionListener, this one stores the selected room number in the ‘comRoom’ variable.
  8. comboBox_2’ ActionListener: This ActionListener stores the selected payment amount in the ‘comPaytm’ variable.
  9. btnPrint’ ActionListener: When the "PRINT RECEIPT" button is clicked, this ActionListener is triggered. It first validates if the search field (‘txtSearch’) is empty. If it is, it shows a message asking the user to enter the search ID. Otherwise, it connects to the database, retrieves the admission details for the specified search ID (‘sNo’), and displays those details in a new window (‘Bill_Status’ frame). It also calculates additional payment and pending amounts based on the selected months and payment amount and shows them on the receipt.
  10. cal(int i, double payment)’ method: This method is used to calculate the extra payment and pending balance based on the selected months and payment amount. It takes the number of months (‘i’) and the payment amount as input, and then calculates the extra payment (if any) and the pending balance.

Overall, the code extends the Hostel Management System by providing functionality to add new admission records and view existing admission details in a table. The "PRINT RECEIPT" button allows the owner to view detailed payment status and information related to a particular admission record.

-------------------------------------

Dashboard -> Applcation

Add New Record -> Application

Search ID -> Application

Search

Delete Record -> Application [3rd Record]

 

-------------------------------------

PAGE - 3: [Bill_Status.java]

Detail Code : 

  1. JFrame’: The class creates a new JFrame called "thirdFrame" to display the bill status GUI.
  2. JLabels and JTextFields: The class uses JLabels and JTextFields to display the resident's name, father's name, room number, and months of stay. It also displays the bill information, including the month of the bill, the amount paid, the pending amount, and any advance payment made.
  3. JButton "Back": This button allows the user to go back to the main menu ("Menu" class) when clicked. The action is handled by the "ActionListener" for this button.
  4. TitledBorder Panels: The class uses TitledBorder panels to group related components and improve the visual organization of the GUI.
  5. "main" method: This method is used for testing the "Bill_Status" class in isolation. When executed, it creates an instance of the "Bill_Status" class and displays the "thirdFrame" window.

In summary, the "Bill_Status" class provides a user interface for displaying the bill details of a hostel resident, including their name, father's name, room number, and payment status. This class is meant to work in conjunction with the "Menu" class, allowing users to access bill details from the main menu.

-------------------------------------

Bill Pending -> Application

Bill Paid -> Application

Advance Bill Paid -> Application

-------------------------------------

MySql

I am using the above schema in SQL for this project.

-------------------------------------

The "Hostel Management System" project is a Java-based application that aims to assist in managing a hostel's operations. It provides various features for both hostel owners/administrators and hostel residents. Below are the main features of this project:

  1. Login Page: The project starts with a login page that ensures only authorized users can access the hostel management system. Users are required to enter their username and password to log in.
  2. Menu: After successful login, the users are directed to the main menu, which provides different options for hostel management.
  3. Add Admission: Hostel administrators can use this feature to add new residents to the hostel. The administrator can input the resident's name, contact number, Aadhar number, father's name, duration of stay (in months), room number, and payment details.
  4. Deletion of Student Records: The "DELETE" button enables the owner to remove a student's admission record from the database by specifying the serial number (sNo), and the table is automatically updated after successful deletion.
  5. Display Residents: This feature allows administrators to view a list of all residents in the hostel, including their serial number, name, Aadhar number, and room number. The list is displayed in a table format.
  6. Search Resident: Administrators can search for a specific resident based on their serial number to view detailed information about that resident, including their name, father's name, room number, months of stay, payment status, pending amount, and advance payment.
  7. Print Receipt: This feature generates a receipt for a specific resident with detailed information, including the name, father's name, room number, months of stay, payment status, pending amount, and advance payment. The receipt is displayed in a separate window and can be printed for record-keeping.
  8. Logout: The system provides a logout option to ensure secure access. Users can log out to exit the hostel management system.

Key Points:

- The project uses a graphical user interface (GUI) implemented using Swing to provide an interactive and user-friendly experience.

- It utilizes MySQL for database management, storing resident information and payment details.

- The "Bill_Status" class handles the display of bill information for a resident, including pending amounts, advance payments, and bill status (paid or pending).

- The project applies proper data validation to ensure that users enter valid information and avoid errors during data entry.

- It calculates pending amounts and advance payments based on the duration of stay and payment made by the resident.

- The project provides appropriate feedback messages to users in case of any missing fields or incorrect inputs.

Overall, the "Hostel Management System" project streamlines the process of managing a hostel, making it easier for administrators to add residents, view resident details, and generate payment receipts. It is an efficient tool for hostel owners to keep track of residents' details and financial transactions.

Download Complete Code

Comments

No comments yet

Download Packet

Reviews Report

Submitted by K SYAM PRASAD (Syampk58)

Download packets of source code on Coders Packet