Coders Packet

Online Ticket Reservation System Using Java Swings

By P. Veera Sai Rakesh

Online Ticket Reservation System is a model that showing that the booking the ticket online using java swings.

Online Reservation System Using Java Swings :

Online reservation System is a simple application that illustrates the reservation and cancellation of a railway train ticket booking system. Through this Reservation System, a practical approach has been taken under study to understand how the online reservation system works. This Online Reservation System will include all the necessary fields that are required for the online reservation system. This Online Reservation System will be easy to use and can be used by any person.

Follow the below steps and proceed to develop :

 =>  Creating a Database of Reservation System.

 =>  Creating Window Pages for the Reservation System.

 =>  Connecting database using JDBC.

1. Creating a Database of Reservation System :

     The database is the main requirement of our project. Since, it consists of details of users, trains, tickets, etc. So we are required to fetch and store the information from and to the database. We can use different types of databases in the project. In our case, we are using MySQL.

Create a database with the following table :

Table_in_project

Ticket_details: This table contains the information about the booked tickets in a train.

Train_details: This table contains the information about the train.

User_details: This table contains the user login details.

 

The structure of the three tables is shown below :

 1. User_details:

descUser

 

2. Train_details:

descTrain

 

3. Ticket_details:

descTicket

 

Create the above-mentioned tables using the above structure.

 

2. Creating Window Pages for the Reservation System :

 Number of modules :

            => Login_Page

            => Registration_Form

            => Reserve_or_Cancel

            => Reservation_Form

            => Select_seat Form

            => Cancellation_Form

 

Description of Modules :              

          Login_Page: 

                        To access this Online Reservation System, each user should have a valid login ID and password. After providing the correct login ID and password, users will be able to access the main system. The window is shown below.

 

login

 

      Registration_Form:

                      If a user doesn't have valid credentials to log in, then the user should sign up first and then try to log in again. As shown in the above picture, the new users can sign up using the Sign Up option above. The registration form will look as follows.

registration

     Reserve_or_Cancel: 

                  This window will be used to decide on reservation or cancellation of train tickets. From this page, we can go to two windows: Reservation_form or Cancellation_Form. As shown below.

ReserveorCancel

      Reservation_Form :

                This is the main window page where the actual reservation process is started. On this page, we have to select the source and destination cities and identify the available trains between those cities. And then you will be prompted to choose your seating in the train coach. That is, you have to select the date of the journey, seat_no, etc. As shown below first figure shows the Reservation_form window and the second one shows the available trains between the source and destination followed by the select_seat window.

Reserve

Identifies available trains   ->

Reserve

 

Select_seat Window ->

seatselection

      Cancellation_Form:

                       This form is used to cancel the booked ticket. The cancellation of a ticket is nothing but the deleting of the ticket details from the ticket database using the PNR Number of the ticket. The PNR number is an identification key that uniquely identifies a ticket.

cancel

3. Connection Database Using JDBC :

Connecting to the database using JDBC plays a crucial role in reserving tickets and canceling tickets. Connect the MySql database with the Java project using the following code snippet.

try {
Class.forName("com.mysql.jdbc.Driver");
 Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/project2?useSSL=false","Username","Your_Password");
}
catch(Exception e1) {
JOptionPane.showMessageDialog(btnAdd, e1);
}

Replace the username and password fields with your username and password to connect to your local host database. Note that you should install MySQL 5.5 command line client in your system as a pre-required application.

We need to use this database connection for the following operations:

 => Registering new users i.e., inserting new values into the user details table

 => Check whether the user credentials are valid or not.

 => Finding the available trains from the train_details table.

 => Storing the ticket_details such as source, destination, date-of-journey etc details into ticket details.

 

Use the following syntax for executing a query using JDBC

Statement st=con.createStatement();
ResultSet rs=st.executeQuery(Query);

ResultSet object contains the rows that are selected by executing the query.

Note: The Login_Page.java contains the main method. Since the process starts by logging in.

 

 

Make sure that your system matches with the below system requirements and software requirements :

System requirements :

       =>RAM  512MB or more

       =>HardDisk 50 GB or more

       =>Processor Pentium IV or above

Software Requirements :

       =>Operating System: Windows XP/2003 or higher version

       =>User Interface: Java Swings

       =>Programming Languages: JDBC, Java core

       =>IDE/WorkBench : Eclipse IDE

       =>Database: MySQL 5.5 command line client

 

Note: Since we have user a with less set of data you can increase the train_details table by inserting more rows into them.

 

 

Download Complete Code

Comments

No comments yet

Download Packet

Reviews Report

Submitted by P. Veera Sai Rakesh (SaiRakesh31)

Download packets of source code on Coders Packet