SlideShare a Scribd company logo
1 of 39
Download to read offline
Java Airline Reservation System
– Travel Smarter, Not Harder
Welcome to this project on developing an Airline Reservation System using Java
and SQLite! This system will consist of four panels – Reservations, Customers,
Flights, and Airports – each of which will have a JTable to display data from the
database and an input panel to take input from the user and store it into the
database.
In this project, we will cover the step-by-step process of designing and implementing
this system, including setting up the database, creating the user interface, and
integrating the functionality to perform various operations such as adding new
reservations, customers, flights, and airports, as well as updating and deleting
existing data.
International flights are those that operate between two or more countries, typically
crossing international boundaries. These flights usually involve longer distances. On
the other hand, domestic flights operate within a single country. Domestic flights are
typically shorter in duration and do not require passengers to go through customs or
immigration procedures.
For this we will be creating a toggle button which will allow the users to switch
between international and domestic flights in the Reservations panel. This button will
update our flight choices to reflect the option we selected using the toggle button.
By the end of this project, you will have a working Airline Reservation System that
can efficiently manage and store customer information, flight schedules, and
reservations, making it an invaluable tool for any airline or travel agency. So let’s get
started!
About Java Airline Reservation System
The objective of this project is to provide a comprehensive guide to developing an
Airline Reservation System using Java and SQLite.
By the end of this project, you will be able to design and implement a system that
can efficiently manage and store customer information, flight schedules, and
reservations. Specifically, you will learn how to set up the database, create the user
interface with JTables, and integrate the functionality to perform various operations
such as adding, updating, and deleting data.
This project aims to equip you with the skills and knowledge necessary to develop a
fully-functional Airline Reservation System.
Prerequisites for Airline Reservation
System using Java
Before starting with this tutorial, you should have the following prerequisites:
■ Basic knowledge of Java programming language, including
object-oriented programming concepts.
■ Understanding of SQL and database concepts.
■ Experience with Eclipse or any other Java Integrated Development
Environment (IDE).
■ Basic knowledge of Swing GUI toolkit for building user interfaces.
■ Familiarity with SQLite database management system.
Download Java Airline Reservation
System Project
Please download the source code of Java Airline Reservation System Project from
the following link: Java Airline Reservation System Project Code
Steps to Create Airline Reservation
System using Java
Following are the steps for developing the Java Airline Reservation System Project:
Step 1: Setting Up the Classes in Eclipse
1. Launch Eclipse and go to “File” > “New” > “Java Project”.
2. Assign a name, such as “Airline Reservation System”.
3. Right-click on the project and select “New” > “Class”.
4. Name the first class, for example, “AirlineReservation”.
5. Repeat steps 3 and 4 to create another class, such as “Database”.
Step 2: Adding SQLite to the Project in Eclipse
Note: Before moving forward, make sure to have the SQLite JAR file downloaded
and saved on your computer. This file can be found on MavenRepository
1. Go to the Project Explorer in Eclipse and right-click on your project.
2. Select “Properties” from the menu.
3. In the Properties window, navigate to “Java Build Path” and click the
“Libraries” tab.
4. Click the “Add External JARs” button and find the SQLite JAR file.
5. Choose the JAR file and press “Open”.
6. Click “OK” to close the Properties window.
Incorporating SQLite into your Eclipse project is now complete after following the
steps outlined above.
Step 3: Implementing the Database class with the
required methods
Below is the complete code for the Database class :
package school.FirstCode;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JComboBox;
import javax.swing.table.DefaultTableModel;
import org.sqlite.SQLiteDataSource;
public class Database {
// declaring connection and datasource variables
static Connection conn;
static SQLiteDataSource ds;
// initialize method to initialize the database with all the tables
public static void dbInit() {
ds = new SQLiteDataSource();
try {
ds = new SQLiteDataSource();
ds.setUrl("jdbc:sqlite:AirlineDB.db");
} catch ( Exception e ) {
e.printStackTrace();
System.exit(0);
}
try {
conn = ds.getConnection();
Statement statement = conn.createStatement();
// Create the airports table
statement.executeUpdate("CREATE TABLE IF NOT EXISTS airports (n"
+ " id INTEGER PRIMARY KEY,n"
+ " name TEXT NOT NULL,n"
+ " city TEXT NOT NULL,n"
+ " country TEXT NOT NULLn"
+ ");");
// Create the flights table
statement.executeUpdate("CREATE TABLE IF NOT EXISTS flights (n"
+ " id INTEGER PRIMARY KEY,n"
+ " departure_airport_id INTEGER NOT NULL,n"
+ " arrival_airport_id INTEGER NOT NULL,n"
+ " departure_time TEXT NOT NULL,n"
+ " arrival_time TEXT NOT NULL,n"
+ " price DECIMAL(10, 2) NOT NULL,n"
+ " domestic TEXT NOT NULL CHECK (domestic IN ('yes', 'no')),n"
+ " CONSTRAINT fk_departure_airportn"
+ " FOREIGN KEY (departure_airport_id)n"
+ " REFERENCES airports (id),n"
+ " CONSTRAINT fk_arrival_airportn"
+ " FOREIGN KEY (arrival_airport_id)n"
+ " REFERENCES airports (id)n"
+ " );n");
// Create the customers table
statement.executeUpdate("CREATE TABLE IF NOT EXISTS customers (n"
+ " id INTEGER PRIMARY KEY,n"
+ " first_name TEXT NOT NULL,n"
+ " last_name TEXT NOT NULL,n"
+ " email TEXT NOT NULL,n"
+ " phone_number TEXTn"
+ ");");
// Create the customers table
statement.executeUpdate("CREATE TABLE IF NOT EXISTS reservations (n"
+ " id INTEGER PRIMARY KEY,n"
+ " customer_id INTEGER NOT NULL,n"
+ " flight_id INTEGER NOT NULL,n"
+ " seat_number TEXT NOT NULL,n"
+ " CONSTRAINT fk_customern"
+ " FOREIGN KEY (customer_id)n"
+ " REFERENCES customers (id),n"
+ " CONSTRAINT fk_flightn"
+ " FOREIGN KEY (flight_id)n"
+ " REFERENCES flights (id)n"
+ ");");
// Closing statement and connection
statement.close();
conn.close();
}catch ( SQLException e ) {
e.printStackTrace();
System.exit( 0 );
}
finally {
try {
if (conn != null) {
conn.close();
}
}catch (SQLException e) {
System.err.println(e);
}
}
}
// Method to get update the reservation table with the data from the database
public static void updateReservations(DefaultTableModel model) throws SQLException {
model.setRowCount(0);
conn = ds.getConnection();
String query = "SELECT * From reservations";
PreparedStatement ps = conn.prepareStatement(query);
ResultSet rs = ps.executeQuery();
// Add data to the table model
while (rs.next()) {
int id = rs.getInt("id");
String customer_id = rs.getString("customer_id");
String flight_id = rs.getString("flight_id");
String seat_number = rs.getString("seat_number");
Object[] row = {id, customer_id, flight_id,seat_number};
model.addRow(row);
}
rs.close();
ps.close();
conn.close();
}
// Method to get update the Flights table with the data from the database
public static void updateFlights(DefaultTableModel model) throws SQLException {
model.setRowCount(0);
conn = ds.getConnection();
String query = "SELECT * From flights";
PreparedStatement ps = conn.prepareStatement(query);
ResultSet rs = ps.executeQuery();
// Add data to the table model
while (rs.next()) {
int id = rs.getInt("id");
int departure_airport = rs.getInt("departure_airport_id");
int arrival_airport = rs.getInt("arrival_airport_id");
String departure_time = rs.getString("departure_time");
String arrival_time = rs.getString("arrival_time");
Float price = rs.getFloat("price");
String domestic = rs.getString("domestic");
Object[] row = {id, departure_airport,
arrival_airport,departure_time,arrival_time,price,domestic};
model.addRow(row);
}
rs.close();
ps.close();
conn.close();
}
// Method to get update the Customers table with the data from the database
public static void updateCustomers(DefaultTableModel model) throws SQLException {
model.setRowCount(0);
conn = ds.getConnection();
String query = "SELECT * From customers";
PreparedStatement ps = conn.prepareStatement(query);
ResultSet rs = ps.executeQuery();
// Add data to the table model
while (rs.next()) {
int id = rs.getInt("id");
String first_name = rs.getString("first_name");
String last_name = rs.getString("last_name");
String email = rs.getString("email");
String phone_number = rs.getString("phone_number");
Object[] row = {id, first_name, last_name,email,phone_number};
model.addRow(row);
}
rs.close();
ps.close();
conn.close();
}
// Method to get update the Airports table with the data from the database
public static void updateAirports(DefaultTableModel model) throws SQLException {
model.setRowCount(0);
conn = ds.getConnection();
String query = "SELECT * From airports";
PreparedStatement ps = conn.prepareStatement(query);
ResultSet rs = ps.executeQuery();
// Add data to the table model
while (rs.next()) {
int id = rs.getInt("id");
String name = rs.getString("name");
String city = rs.getString("city");
String country = rs.getString("country");
Object[] row = {id, name, city,country};
model.addRow(row);
}
rs.close();
ps.close();
conn.close();
}
// Method to delete an specific item from a specific table
public static void delete(String tableName,String id) throws SQLException {
conn = ds.getConnection();
String query = "DELETE FROM "+tableName+" WHERE id = "+id+";";
Statement stmt = conn.createStatement();
stmt.execute(query);
stmt.close();
conn.close();
}
// Method to update jcomboBoxes with the required field values
public static void updateBox(JComboBox<String> cbx,String tableName,String
domestic_status) throws SQLException {
cbx.removeAllItems();
conn = ds.getConnection();
String query = "SELECT id FROM "+tableName+" WHERE domestic = '"+domestic_status+"';";
PreparedStatement ps = conn.prepareStatement(query);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
cbx.addItem(rs.getString("id"));
}
ps.close();
conn.close();
}
public static void updateBox(JComboBox<String> cbx,String tableName) throws
SQLException {
cbx.removeAllItems();
conn = ds.getConnection();
String query = "SELECT id FROM "+tableName+";";
PreparedStatement ps = conn.prepareStatement(query);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
cbx.addItem(rs.getString("id"));
}
ps.close();
conn.close();
}
// Method to add the reservations data into the reservations table
public static void addReservation(int id,int custID,int flightID,String seatNum)
throws SQLException {
conn = ds.getConnection();
PreparedStatement ps =conn.prepareStatement("INSERT INTO "
+ "reservations(id,customer_id,flight_id,seat_number) "
+ "VALUES(?,?,?,?)");
ps.setInt(1, id);
ps.setInt(2, flightID);
ps.setInt(3, custID);
ps.setString(4, seatNum);
ps.executeUpdate();
ps.close();
conn.close();
}
// Method to add the Customer data into the Customers table
public static void addCustomer(int id,String first_name,String last_name,String
email,String phone) throws SQLException {
conn = ds.getConnection();
PreparedStatement ps =conn.prepareStatement("INSERT INTO "
+ "customers(id,first_name,last_name,email,phone_number) "
+ "VALUES(?,?,?,?,?)");
ps.setInt(1, id);
ps.setString(2, first_name);
ps.setString(3, last_name);
ps.setString(4, email);
ps.setString(5, phone);
ps.executeUpdate();
ps.close();
conn.close();
}
// Method to add the Flight data into the Flights table
public static void addFlight(int id,int departure_ap_id,int arrival_ap_id,String
departure_time,String arrival_time,float price,String domestic) throws SQLException {
conn = ds.getConnection();
PreparedStatement ps =conn.prepareStatement("INSERT INTO "
+
"flights(id,departure_airport_id,arrival_airport_id,departure_time,arrival_time,price,
domestic) "
+ "VALUES(?,?,?,?,?,?,?)");
ps.setInt(1, id);
ps.setInt(2, departure_ap_id);
ps.setInt(3, arrival_ap_id);
ps.setString(4, departure_time);
ps.setString(5, arrival_time);
ps.setFloat(6, price);
ps.setString(7,domestic);
ps.executeUpdate();
ps.close();
conn.close();
}
// Method to add the Airport data into the Airports table
public static void addAirport(int id,String name,String city,String country ) throws
SQLException {
conn = ds.getConnection();
PreparedStatement ps =conn.prepareStatement("INSERT INTO "
+ "airports(id,name,city,country) "
+ "VALUES(?,?,?,?)");
ps.setInt(1, id);
ps.setString(2, name);
ps.setString(3, city);
ps.setString(4, country);
ps.executeUpdate();
ps.close();
conn.close();
}
}
■ dbInit() – This function initializes the database by creating tables for
airports, flights, customers, and reservations using SQLite queries.
■ updateReservations(DefaultTableModel model) – This function updates
the reservations table from the database and sets the data in the given
table model. It retrieves all the data from the reservations table and adds
them to the table model.
■ updateFlights(DefaultTableModel model) – This function updates the
flights table from the database and sets the data in the given table model.
It retrieves all the data from the flights table and adds them to the table
model.
■ updateCustomers(DefaultTableModel model) – This function updates the
customers table from the database and sets the data in the given table
model. It retrieves all the data from the customers table and adds them to
the table model.
■ updateAirports(DefaultTableModel model) – This function updates the
airports table from the database and sets the data in the given model.It
retrieves all the data from the Airport table and adds them to the table
model.
Similarly, there are functions to add data to the database like
addFlight,addCustomer, etc. Then there’s a delete function that delete the data from
the database by using the id field and the table’s name and lastly, the updateBox
function updates the combo boxes with relevant data.
All these functions connect to the database using the ds (SQLiteDataSource) object
and execute SQL queries to fetch data from the tables. They also use the
PreparedStatement object to execute SQL queries with parameters. Once the data
is fetched from the tables, it is added to the DefaultTableModel object that is passed
as a parameter to these functions. Finally, the connection to the database is closed
after executing the queries.
Step 3: Implementing the AirlineReservation
Below is the complete code for the AirlineReservation class :
package school.FirstCode;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import java.awt.Color;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.border.LineBorder;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.JButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JToggleButton;
public class AirlineReservation {
private JFrame frmAirlineReservatoinSystem;
private JTextField resIDField;
private JTextField seatField;
private JTable reservationsTable;
private JTextField custIDField;
private JTextField firstNamefield;
private JTable customerTable;
private JTextField lastNameField;
private JTextField emailField;
private JTextField textField_1;
private JTextField airportIDField;
private JTextField airportNameField;
private JTextField cityField;
private JTextField countryField;
private JTable airportsTable;
private JTextField flightIDField;
private JTextField departureTimeField;
private JTextField arrivalTimeField;
private JTextField priceField;
private JTable flightTable;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Database.dbInit();
AirlineReservation window = new AirlineReservation();
window.frmAirlineReservatoinSystem.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public AirlineReservation() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frmAirlineReservatoinSystem = new JFrame();
frmAirlineReservatoinSystem.setTitle("Airline Reservation System");
frmAirlineReservatoinSystem.setBounds(100, 100, 800, 500);
frmAirlineReservatoinSystem.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frmAirlineReservatoinSystem.getContentPane().setLayout(new BorderLayout(0, 0));
frmAirlineReservatoinSystem.setResizable(false);
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
frmAirlineReservatoinSystem.getContentPane().add(tabbedPane);
JPanel reservationsPanel = new JPanel();
tabbedPane.addTab("Reservations", null, reservationsPanel, null);
reservationsPanel.setLayout(null);
JPanel resInputPanel = new JPanel();
resInputPanel.setBounds(5, 53, 281, 349);
resInputPanel.setBorder(new TitledBorder(new LineBorder(new Color(0, 0, 0), 5), "Add
Reservation", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
resInputPanel.setBackground(new Color(192, 191, 188));
reservationsPanel.add(resInputPanel);
resInputPanel.setLayout(new GridLayout(0, 2, 0, 10));
JLabel lblID = new JLabel("ID");
resInputPanel.add(lblID);
resIDField = new JTextField();
resIDField.setColumns(10);
resInputPanel.add(resIDField);
JLabel lblSeatNo = new JLabel("Seat Number");
resInputPanel.add(lblSeatNo);
seatField = new JTextField();
seatField.setColumns(10);
resInputPanel.add(seatField);
JLabel lblflightID = new JLabel("Flight ID");
resInputPanel.add(lblflightID);
JComboBox<String> flightComboBox = new JComboBox<String>();
resInputPanel.add(flightComboBox);
JLabel lblCustID = new JLabel("Customer ID");
resInputPanel.add(lblCustID);
JComboBox<String> custComboBox = new JComboBox<String>();
resInputPanel.add(custComboBox);
JScrollPane reservationscrollPane = new JScrollPane();
reservationscrollPane.setBounds(295, 53, 500, 349);
reservationsPanel.add(reservationscrollPane);
String[] reservationColumsNames = {"ID","Customer ID","Flight ID","Seat No."};
DefaultTableModel reservationsModel = new DefaultTableModel(reservationColumsNames,0);
reservationsTable = new JTable();
reservationsTable.setModel(reservationsModel);
reservationscrollPane.setViewportView(reservationsTable);
JButton btnLoadReservations = new JButton("Load");
btnLoadReservations.setBackground(new Color(188,108,37));
btnLoadReservations.setBounds(295, 25, 100, 30);
btnLoadReservations.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
Database.updateReservations(reservationsModel);
} catch (SQLException e1) {
e1.printStackTrace();
}
}
});
reservationsPanel.add(btnLoadReservations);
JToggleButton tglbtnDomesticFlights = new JToggleButton("Domestic Flights",true);
tglbtnDomesticFlights.setBackground(new Color(188,108,37));
tglbtnDomesticFlights.setBounds(400, 25, 200, 30);
tglbtnDomesticFlights.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (tglbtnDomesticFlights.isSelected()) {
tglbtnDomesticFlights.setText("Domestic Flights");
try {
Database.updateBox(flightComboBox,"flights", "yes");
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
} else {
tglbtnDomesticFlights.setText("International Flights");
try {
Database.updateBox(flightComboBox,"flights", "no");
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
});
reservationsPanel.add(tglbtnDomesticFlights);
JButton btnaddReservation = new JButton("Add");
btnaddReservation.setBackground(new Color(188, 108, 37));
btnaddReservation.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
Database.addReservation(Integer.valueOf(resIDField.getText()),
Integer.valueOf(custComboBox.getSelectedItem().toString()),
Integer.valueOf(flightComboBox.getSelectedItem().toString()),
seatField.getText());
Database.updateReservations(reservationsModel);
JOptionPane.showMessageDialog(btnaddReservation, "Added
successfully","Success",JOptionPane.INFORMATION_MESSAGE);
} catch (NumberFormatException e1) {
JOptionPane.showMessageDialog(btnaddReservation, "Enter Valid ID","Invalid
ID",JOptionPane.INFORMATION_MESSAGE);
e1.printStackTrace();
} catch (SQLException e1) {
JOptionPane.showMessageDialog(btnaddReservation, "Can't
Add","Error",JOptionPane.ERROR_MESSAGE);
e1.printStackTrace();
}
}
});
resInputPanel.add(btnaddReservation);
JButton btnRemoveReservation = new JButton("Remove");
btnRemoveReservation.setBackground(new Color(188, 108, 37));
btnRemoveReservation.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
Database.delete("reservations",resIDField.getText());
Database.updateReservations(reservationsModel);
JOptionPane.showMessageDialog(btnRemoveReservation, "Deleted","success"
,JOptionPane.INFORMATION_MESSAGE);
} catch (SQLException e1) {
JOptionPane.showMessageDialog(btnRemoveReservation, "Can't Delete","Error"
,JOptionPane.ERROR_MESSAGE);
e1.printStackTrace();
}
}
});
resInputPanel.add(btnRemoveReservation);
JPanel customerPanel = new JPanel();
tabbedPane.addTab("Customers", null, customerPanel, null);
customerPanel.setLayout(null);
JPanel custInputPanel = new JPanel();
custInputPanel.setBorder(new TitledBorder(new LineBorder(new Color(0, 0, 0), 5), "Add
Customers", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
custInputPanel.setBackground(new Color(192, 191, 188));
custInputPanel.setBounds(12, 36, 281, 349);
customerPanel.add(custInputPanel);
custInputPanel.setLayout(new GridLayout(0, 2, 0, 10));
JLabel lblID_1 = new JLabel("ID");
custInputPanel.add(lblID_1);
custIDField = new JTextField();
custIDField.setColumns(10);
custInputPanel.add(custIDField);
JLabel lblFirstName = new JLabel("First Name");
custInputPanel.add(lblFirstName);
firstNamefield = new JTextField();
firstNamefield.setColumns(10);
custInputPanel.add(firstNamefield);
JLabel lblLastName = new JLabel("Last Name");
custInputPanel.add(lblLastName);
lastNameField = new JTextField();
lastNameField.setColumns(10);
custInputPanel.add(lastNameField);
JLabel lblEmail = new JLabel("Email");
custInputPanel.add(lblEmail);
emailField = new JTextField();
emailField.setColumns(10);
custInputPanel.add(emailField);
JLabel phoneNumField = new JLabel("Phone no.");
custInputPanel.add(phoneNumField);
textField_1 = new JTextField();
textField_1.setColumns(10);
custInputPanel.add(textField_1);
JScrollPane customerscrollPane = new JScrollPane();
customerscrollPane.setBounds(305, 35, 500, 349);
customerPanel.add(customerscrollPane);
String[] custColumnName = {"ID","First Name","Last Name","Email","Phone"};
DefaultTableModel customerModel = new DefaultTableModel(custColumnName,0);
customerTable = new JTable();
customerTable.setModel(customerModel);
customerscrollPane.setViewportView(customerTable);
JButton btnaddCustomer = new JButton("Add");
btnaddCustomer.setBackground(new Color(188, 108, 37));
btnaddCustomer.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
Database.addCustomer(Integer.valueOf(custIDField.getText()),
firstNamefield.getText(),
lastNameField.getText(),
emailField.getText(),
phoneNumField.getText());
Database.updateCustomers(customerModel);
JOptionPane.showMessageDialog(btnaddCustomer, "Added Successfully","success"
,JOptionPane.INFORMATION_MESSAGE);
} catch (NumberFormatException e1) {
JOptionPane.showMessageDialog(btnaddCustomer, "Enter Valid ID","Invalid ID"
,JOptionPane.ERROR_MESSAGE);
e1.printStackTrace();
} catch (SQLException e1) {
JOptionPane.showMessageDialog(btnaddCustomer, "Can't add","Error"
,JOptionPane.INFORMATION_MESSAGE);
e1.printStackTrace();
}
}
});
custInputPanel.add(btnaddCustomer);
JButton btnRemoveCustomer = new JButton("Remove");
btnRemoveCustomer.setBackground(new Color(188, 108, 37));
btnRemoveCustomer.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
Database.delete("customers",custIDField.getText());
Database.updateCustomers(customerModel);
JOptionPane.showMessageDialog(btnRemoveCustomer, "Deleted","success"
,JOptionPane.INFORMATION_MESSAGE);
} catch (SQLException e1) {
JOptionPane.showMessageDialog(btnRemoveCustomer, "Can't Delete","Error"
,JOptionPane.ERROR_MESSAGE);
e1.printStackTrace();
}
}
});
custInputPanel.add(btnRemoveCustomer);
JButton btnLoadCustomers = new JButton("Load All");
btnLoadCustomers.setBackground(new Color(188, 108, 37));
btnLoadCustomers.setBounds(305, 10, 100, 30);
btnLoadCustomers.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
Database.updateCustomers(customerModel);
} catch (SQLException e1) {
e1.printStackTrace();
}
}
});
customerPanel.add(btnLoadCustomers);
JPanel flightsPanel = new JPanel();
tabbedPane.addTab("Flights", null, flightsPanel, null);
flightsPanel.setLayout(null);
JPanel flightsInputPanel = new JPanel();
flightsInputPanel.setBorder(new TitledBorder(new LineBorder(new Color(0, 0, 0), 5),
"Add Flights", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
flightsInputPanel.setBackground(new Color(192, 191, 188));
flightsInputPanel.setBounds(0, 43, 281, 349);
flightsPanel.add(flightsInputPanel);
flightsInputPanel.setLayout(new GridLayout(0, 2, 0, 10));
JLabel lblID_1_1 = new JLabel("ID");
flightsInputPanel.add(lblID_1_1);
flightIDField = new JTextField();
flightIDField.setColumns(10);
flightsInputPanel.add(flightIDField);
JLabel departure = new JLabel("Departure Time");
flightsInputPanel.add(departure);
departureTimeField = new JTextField();
departureTimeField.setColumns(10);
flightsInputPanel.add(departureTimeField);
JLabel lblArrival = new JLabel("Arrival Time");
flightsInputPanel.add(lblArrival);
arrivalTimeField = new JTextField();
arrivalTimeField.setColumns(10);
flightsInputPanel.add(arrivalTimeField);
JLabel lblPrice = new JLabel("Price");
flightsInputPanel.add(lblPrice);
priceField = new JTextField();
priceField.setColumns(10);
flightsInputPanel.add(priceField);
JLabel lbldepAirportID = new JLabel("Dep Airport ID");
flightsInputPanel.add(lbldepAirportID);
JComboBox<String> depAirportIDComboBox = new JComboBox<String>();
flightsInputPanel.add(depAirportIDComboBox);
JLabel lblArrAirportID = new JLabel("Arr Airport ID");
flightsInputPanel.add(lblArrAirportID);
JComboBox<String> arrAirportIDComboBox = new JComboBox<String>();
flightsInputPanel.add(arrAirportIDComboBox);
JScrollPane flightscrollPane = new JScrollPane();
flightscrollPane.setBounds(290, 43, 500, 349);
flightsPanel.add(flightscrollPane);
String[] flightColumns = {"Id","Dp. Ap. ID","Arr. Ap. ID","Dp Time","Arr
Time","Price","Domestic"};
DefaultTableModel flightModel = new DefaultTableModel(flightColumns,0);
flightTable = new JTable();
flightTable.setModel(flightModel);
flightscrollPane.setViewportView(flightTable);
JLabel lblDomestic = new JLabel("Domestic");
flightsInputPanel.add(lblDomestic);
JComboBox<String> arrDomesticBox = new JComboBox<String>();
arrDomesticBox.addItem("Yes");
arrDomesticBox.addItem("No");
flightsInputPanel.add(arrDomesticBox);
JButton btnaddFlight = new JButton("Add");
btnaddFlight.setBackground(new Color(188, 108, 37));
btnaddFlight.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
Database.addFlight( Integer.valueOf(flightIDField.getText()),
Integer.valueOf(depAirportIDComboBox.getSelectedItem().toString()),
Integer.valueOf(arrAirportIDComboBox.getSelectedItem().toString()),
departureTimeField.getText(),
arrivalTimeField.getText(),
Float.valueOf(priceField.getText()),
(String)arrDomesticBox.getSelectedItem());
Database.updateFlights(flightModel);
JOptionPane.showMessageDialog(btnaddFlight, "Added Successfully","Success"
,JOptionPane.INFORMATION_MESSAGE);
} catch (NumberFormatException e1) {
JOptionPane.showMessageDialog(btnaddFlight, "Enter Valid ID/price","Invalid ID/price"
,JOptionPane.ERROR_MESSAGE);
e1.printStackTrace();
} catch (SQLException e1) {
JOptionPane.showMessageDialog(btnaddFlight, "Can't Add","Error"
,JOptionPane.ERROR_MESSAGE);
e1.printStackTrace();
}
}
});
flightsInputPanel.add(btnaddFlight);
JButton btnRemoveFlight = new JButton("Remove");
btnRemoveFlight.setBackground(new Color(188, 108, 37));
btnRemoveFlight.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
Database.delete("flights", flightIDField.getText());
Database.updateFlights(flightModel);
JOptionPane.showMessageDialog(btnRemoveFlight, "Deleted Successfully","Success"
,JOptionPane.INFORMATION_MESSAGE);
} catch (SQLException e1) {
JOptionPane.showMessageDialog(btnRemoveFlight, "Can't Delete","Error"
,JOptionPane.ERROR_MESSAGE);
e1.printStackTrace();
}
}
});
flightsInputPanel.add(btnRemoveFlight);
JButton btnLoadFlights = new JButton("Load All");
btnLoadFlights.setBackground(new Color(188, 108, 37));
btnLoadFlights.setBounds(290, 12, 100, 30);
btnLoadFlights.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
Database.updateFlights(flightModel);
} catch (SQLException e1) {
e1.printStackTrace();
}
}
});
flightsPanel.add(btnLoadFlights);
JPanel airportPanel = new JPanel();
tabbedPane.addTab("Airport", null, airportPanel, null);
airportPanel.setLayout(null);
JPanel airportInputPanel = new JPanel();
airportInputPanel.setBorder(new TitledBorder(new LineBorder(new Color(0, 0, 0), 5),
"Add Airport", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
airportInputPanel.setBackground(new Color(192, 191, 188));
airportInputPanel.setBounds(0, 40, 281, 349);
airportPanel.add(airportInputPanel);
airportInputPanel.setLayout(new GridLayout(0, 2, 0, 10));
JLabel lblID_2 = new JLabel("ID");
airportInputPanel.add(lblID_2);
airportIDField = new JTextField();
airportIDField.setColumns(10);
airportInputPanel.add(airportIDField);
JLabel lblairportName = new JLabel("Name");
airportInputPanel.add(lblairportName);
airportNameField = new JTextField();
airportNameField.setColumns(10);
airportInputPanel.add(airportNameField);
JLabel lblCity = new JLabel("City");
airportInputPanel.add(lblCity);
cityField = new JTextField();
cityField.setColumns(10);
airportInputPanel.add(cityField);
JLabel lblCountry = new JLabel("Country");
airportInputPanel.add(lblCountry);
countryField = new JTextField();
countryField.setColumns(10);
airportInputPanel.add(countryField);
JScrollPane airportscrollPane = new JScrollPane();
airportscrollPane.setBounds(290, 40, 500, 349);
airportPanel.add(airportscrollPane);
String[] apModelColumns = {"ID","Name","City","Country"};
DefaultTableModel airportTableModel = new DefaultTableModel(apModelColumns,0);
airportsTable = new JTable();
airportscrollPane.setViewportView(airportsTable);
airportsTable.setModel(airportTableModel);
JButton btnaddAirport = new JButton("Add");
btnaddAirport.setBackground(new Color(188, 108, 37));
btnaddAirport.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
Database.addAirport(Integer.valueOf(airportIDField.getText()),
airportNameField.getText(),
cityField.getText(),
countryField.getText());
Database.updateAirports(airportTableModel);
JOptionPane.showMessageDialog(btnaddAirport, "Added Successfully","Success"
,JOptionPane.INFORMATION_MESSAGE);
} catch (NumberFormatException e1) {
JOptionPane.showMessageDialog(btnaddAirport, "Enter Valid ID","Invalid ID"
,JOptionPane.ERROR_MESSAGE);
e1.printStackTrace();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
airportInputPanel.add(btnaddAirport);
JButton btnRemoveAirport = new JButton("Remove");
btnRemoveAirport.setBackground(new Color(188, 108, 37));
btnRemoveAirport.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
Database.delete("airports", airportIDField.getText());
Database.updateAirports(airportTableModel);
JOptionPane.showMessageDialog(btnRemoveAirport, "Successfully
Deleted","Success",JOptionPane.INFORMATION_MESSAGE);
} catch (SQLException e1) {
JOptionPane.showMessageDialog(btnRemoveAirport, "Can't
Delete","Error",JOptionPane.ERROR_MESSAGE);
e1.printStackTrace();
}
}
});
airportInputPanel.add(btnRemoveAirport);
JButton btnLoadAirports = new JButton("Load All");
btnLoadAirports.setBackground(new Color(188, 108, 37));
btnLoadAirports.setBounds(289, 12, 100, 30);
btnLoadAirports.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
Database.updateAirports(airportTableModel);
} catch (SQLException e1) {
e1.printStackTrace();
}
}
});
airportPanel.add(btnLoadAirports);
try {
Database.updateBox(arrAirportIDComboBox, "airports");
Database.updateBox(depAirportIDComboBox, "airports");
Database.updateBox(flightComboBox, "flights","yes");
Database.updateBox(custComboBox, "customers");
} catch (SQLException e1) {
e1.printStackTrace();
}
}
}
Summary
This project demonstrates the use of SQLite and JDBC to create and manage a
database for an airline reservation system. The project covers the creation of a
database, creating tables and establishing relationships between them, adding data
to the database, and querying the database to retrieve data.
The code includes methods to update tables in the database and retrieve data from
them, which are demonstrated through the creation of a GUI that allows the user to
view flights, airports, customers, and reservations. The GUI also allows the user to
add new flights and customers to the database, as well as create and delete
reservations.
Overall, this project provides a practical example of using JDBC and SQL to create a
database and perform basic CRUD (Create, Read, Update, Delete) operations on it.
It also demonstrates the use of a graphical user interface (GUI) to interact with the
database, which can make it more accessible to end-users.

More Related Content

What's hot

PYTHON CURRENT TREND APPLICATIONS- AN OVERVIEW
PYTHON CURRENT TREND APPLICATIONS- AN OVERVIEWPYTHON CURRENT TREND APPLICATIONS- AN OVERVIEW
PYTHON CURRENT TREND APPLICATIONS- AN OVERVIEWEditorIJAERD
 
Flutter: Future of App Development
Flutter: Future of App DevelopmentFlutter: Future of App Development
Flutter: Future of App Development9 series
 
1.-Introduction-to-Dart.pdf
1.-Introduction-to-Dart.pdf1.-Introduction-to-Dart.pdf
1.-Introduction-to-Dart.pdfSamySiddhan
 
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAndroid User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAhsanul Karim
 
Exception Handling in VB.Net
Exception Handling in VB.NetException Handling in VB.Net
Exception Handling in VB.Netrishisingh190
 
Social Network Gaming
Social Network GamingSocial Network Gaming
Social Network GamingAshkan Mehran
 
Big Data Tutorial For Beginners | What Is Big Data | Big Data Tutorial | Hado...
Big Data Tutorial For Beginners | What Is Big Data | Big Data Tutorial | Hado...Big Data Tutorial For Beginners | What Is Big Data | Big Data Tutorial | Hado...
Big Data Tutorial For Beginners | What Is Big Data | Big Data Tutorial | Hado...Edureka!
 
Zinnar -The Palestinian e-Government Interoperability Framework
Zinnar -The Palestinian e-Government Interoperability FrameworkZinnar -The Palestinian e-Government Interoperability Framework
Zinnar -The Palestinian e-Government Interoperability FrameworkMustafa Jarrar
 
Introduction to Python IDLE | IDLE Tutorial | Edureka
Introduction to Python IDLE | IDLE Tutorial | EdurekaIntroduction to Python IDLE | IDLE Tutorial | Edureka
Introduction to Python IDLE | IDLE Tutorial | EdurekaEdureka!
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to DjangoKnoldus Inc.
 
What Is Data Science? Data Science Course - Data Science Tutorial For Beginne...
What Is Data Science? Data Science Course - Data Science Tutorial For Beginne...What Is Data Science? Data Science Course - Data Science Tutorial For Beginne...
What Is Data Science? Data Science Course - Data Science Tutorial For Beginne...Edureka!
 
Overview of python 2019
Overview of python 2019Overview of python 2019
Overview of python 2019Samir Mohanty
 
Data visualization in Python
Data visualization in PythonData visualization in Python
Data visualization in PythonMarc Garcia
 

What's hot (20)

CLOUD COMPUTING_proposal
CLOUD COMPUTING_proposalCLOUD COMPUTING_proposal
CLOUD COMPUTING_proposal
 
Big data
Big dataBig data
Big data
 
PYTHON CURRENT TREND APPLICATIONS- AN OVERVIEW
PYTHON CURRENT TREND APPLICATIONS- AN OVERVIEWPYTHON CURRENT TREND APPLICATIONS- AN OVERVIEW
PYTHON CURRENT TREND APPLICATIONS- AN OVERVIEW
 
IoT on Azure
IoT on AzureIoT on Azure
IoT on Azure
 
Flutter: Future of App Development
Flutter: Future of App DevelopmentFlutter: Future of App Development
Flutter: Future of App Development
 
1.-Introduction-to-Dart.pdf
1.-Introduction-to-Dart.pdf1.-Introduction-to-Dart.pdf
1.-Introduction-to-Dart.pdf
 
Introduction of python
Introduction of pythonIntroduction of python
Introduction of python
 
Intro to Jupyter Notebooks
Intro to Jupyter NotebooksIntro to Jupyter Notebooks
Intro to Jupyter Notebooks
 
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAndroid User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
 
Introduction to android testing
Introduction to android testingIntroduction to android testing
Introduction to android testing
 
Exception Handling in VB.Net
Exception Handling in VB.NetException Handling in VB.Net
Exception Handling in VB.Net
 
Social Network Gaming
Social Network GamingSocial Network Gaming
Social Network Gaming
 
SQLite database in android
SQLite database in androidSQLite database in android
SQLite database in android
 
Big Data Tutorial For Beginners | What Is Big Data | Big Data Tutorial | Hado...
Big Data Tutorial For Beginners | What Is Big Data | Big Data Tutorial | Hado...Big Data Tutorial For Beginners | What Is Big Data | Big Data Tutorial | Hado...
Big Data Tutorial For Beginners | What Is Big Data | Big Data Tutorial | Hado...
 
Zinnar -The Palestinian e-Government Interoperability Framework
Zinnar -The Palestinian e-Government Interoperability FrameworkZinnar -The Palestinian e-Government Interoperability Framework
Zinnar -The Palestinian e-Government Interoperability Framework
 
Introduction to Python IDLE | IDLE Tutorial | Edureka
Introduction to Python IDLE | IDLE Tutorial | EdurekaIntroduction to Python IDLE | IDLE Tutorial | Edureka
Introduction to Python IDLE | IDLE Tutorial | Edureka
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
What Is Data Science? Data Science Course - Data Science Tutorial For Beginne...
What Is Data Science? Data Science Course - Data Science Tutorial For Beginne...What Is Data Science? Data Science Course - Data Science Tutorial For Beginne...
What Is Data Science? Data Science Course - Data Science Tutorial For Beginne...
 
Overview of python 2019
Overview of python 2019Overview of python 2019
Overview of python 2019
 
Data visualization in Python
Data visualization in PythonData visualization in Python
Data visualization in Python
 

Similar to Java Airline Reservation System – Travel Smarter, Not Harder.pdf

Laravel 8 export data as excel file with example
Laravel 8 export data as excel file with exampleLaravel 8 export data as excel file with example
Laravel 8 export data as excel file with exampleKaty Slemon
 
Airline reservation system
Airline reservation systemAirline reservation system
Airline reservation systemUnsa Jawaid
 
How to use lekhoniya.pdf
How to use lekhoniya.pdfHow to use lekhoniya.pdf
How to use lekhoniya.pdfSubhamMandal40
 
Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)Fafadia Tech
 
Vaadin 7 CN
Vaadin 7 CNVaadin 7 CN
Vaadin 7 CNjojule
 
Angular 2 Upgrade: Migration von AngularJS 1.x zu 2.0
Angular 2 Upgrade: Migration von AngularJS 1.x zu 2.0Angular 2 Upgrade: Migration von AngularJS 1.x zu 2.0
Angular 2 Upgrade: Migration von AngularJS 1.x zu 2.0Manfred Steyer
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)Igor Bronovskyy
 
Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Eliran Eliassy
 
Practical AngularJS
Practical AngularJSPractical AngularJS
Practical AngularJSWei Ru
 
Building a js widget
Building a js widgetBuilding a js widget
Building a js widgetTudor Barbu
 
20150728 100분만에 배우는 windows 10 앱 개발
20150728 100분만에 배우는 windows 10 앱 개발20150728 100분만에 배우는 windows 10 앱 개발
20150728 100분만에 배우는 windows 10 앱 개발영욱 김
 
JavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de DatosJavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de Datosphilogb
 
Boston Computing Review - Java Server Pages
Boston Computing Review - Java Server PagesBoston Computing Review - Java Server Pages
Boston Computing Review - Java Server PagesJohn Brunswick
 

Similar to Java Airline Reservation System – Travel Smarter, Not Harder.pdf (20)

Laravel 8 export data as excel file with example
Laravel 8 export data as excel file with exampleLaravel 8 export data as excel file with example
Laravel 8 export data as excel file with example
 
Jsf intro
Jsf introJsf intro
Jsf intro
 
Nodejs.meetup
Nodejs.meetupNodejs.meetup
Nodejs.meetup
 
Airline reservation system
Airline reservation systemAirline reservation system
Airline reservation system
 
Dojo and Adobe AIR
Dojo and Adobe AIRDojo and Adobe AIR
Dojo and Adobe AIR
 
How to use lekhoniya.pdf
How to use lekhoniya.pdfHow to use lekhoniya.pdf
How to use lekhoniya.pdf
 
Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)
 
Vaadin 7 CN
Vaadin 7 CNVaadin 7 CN
Vaadin 7 CN
 
Framework
FrameworkFramework
Framework
 
Angular 2 Upgrade: Migration von AngularJS 1.x zu 2.0
Angular 2 Upgrade: Migration von AngularJS 1.x zu 2.0Angular 2 Upgrade: Migration von AngularJS 1.x zu 2.0
Angular 2 Upgrade: Migration von AngularJS 1.x zu 2.0
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics
 
Ext JS Introduction
Ext JS IntroductionExt JS Introduction
Ext JS Introduction
 
Practical AngularJS
Practical AngularJSPractical AngularJS
Practical AngularJS
 
Building a js widget
Building a js widgetBuilding a js widget
Building a js widget
 
Having Fun with Play
Having Fun with PlayHaving Fun with Play
Having Fun with Play
 
20150728 100분만에 배우는 windows 10 앱 개발
20150728 100분만에 배우는 windows 10 앱 개발20150728 100분만에 배우는 windows 10 앱 개발
20150728 100분만에 배우는 windows 10 앱 개발
 
JavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de DatosJavaScript para Graficos y Visualizacion de Datos
JavaScript para Graficos y Visualizacion de Datos
 
I Feel Pretty
I Feel PrettyI Feel Pretty
I Feel Pretty
 
Boston Computing Review - Java Server Pages
Boston Computing Review - Java Server PagesBoston Computing Review - Java Server Pages
Boston Computing Review - Java Server Pages
 

More from SudhanshiBakre1

Float Data Type in C.pdf
Float Data Type in C.pdfFloat Data Type in C.pdf
Float Data Type in C.pdfSudhanshiBakre1
 
IoT Hardware – The Backbone of Smart Devices.pdf
IoT Hardware – The Backbone of Smart Devices.pdfIoT Hardware – The Backbone of Smart Devices.pdf
IoT Hardware – The Backbone of Smart Devices.pdfSudhanshiBakre1
 
Internet of Things – Contiki.pdf
Internet of Things – Contiki.pdfInternet of Things – Contiki.pdf
Internet of Things – Contiki.pdfSudhanshiBakre1
 
Java abstract Keyword.pdf
Java abstract Keyword.pdfJava abstract Keyword.pdf
Java abstract Keyword.pdfSudhanshiBakre1
 
Collections in Python - Where Data Finds Its Perfect Home.pdf
Collections in Python - Where Data Finds Its Perfect Home.pdfCollections in Python - Where Data Finds Its Perfect Home.pdf
Collections in Python - Where Data Finds Its Perfect Home.pdfSudhanshiBakre1
 
File Handling in Java.pdf
File Handling in Java.pdfFile Handling in Java.pdf
File Handling in Java.pdfSudhanshiBakre1
 
Types of AI you should know.pdf
Types of AI you should know.pdfTypes of AI you should know.pdf
Types of AI you should know.pdfSudhanshiBakre1
 
Annotations in Java with Example.pdf
Annotations in Java with Example.pdfAnnotations in Java with Example.pdf
Annotations in Java with Example.pdfSudhanshiBakre1
 
Top Cryptocurrency Exchanges of 2023.pdf
Top Cryptocurrency Exchanges of 2023.pdfTop Cryptocurrency Exchanges of 2023.pdf
Top Cryptocurrency Exchanges of 2023.pdfSudhanshiBakre1
 
Epic Python Face-Off -Methods vs.pdf
Epic Python Face-Off -Methods vs.pdfEpic Python Face-Off -Methods vs.pdf
Epic Python Face-Off -Methods vs.pdfSudhanshiBakre1
 
Django Tutorial_ Let’s take a deep dive into Django’s web framework.pdf
Django Tutorial_ Let’s take a deep dive into Django’s web framework.pdfDjango Tutorial_ Let’s take a deep dive into Django’s web framework.pdf
Django Tutorial_ Let’s take a deep dive into Django’s web framework.pdfSudhanshiBakre1
 
Benefits Of IoT Salesforce.pdf
Benefits Of IoT Salesforce.pdfBenefits Of IoT Salesforce.pdf
Benefits Of IoT Salesforce.pdfSudhanshiBakre1
 
Epic Python Face-Off -Methods vs. Functions.pdf
Epic Python Face-Off -Methods vs. Functions.pdfEpic Python Face-Off -Methods vs. Functions.pdf
Epic Python Face-Off -Methods vs. Functions.pdfSudhanshiBakre1
 
Python Classes_ Empowering Developers, Enabling Breakthroughs.pdf
Python Classes_ Empowering Developers, Enabling Breakthroughs.pdfPython Classes_ Empowering Developers, Enabling Breakthroughs.pdf
Python Classes_ Empowering Developers, Enabling Breakthroughs.pdfSudhanshiBakre1
 

More from SudhanshiBakre1 (20)

IoT Security.pdf
IoT Security.pdfIoT Security.pdf
IoT Security.pdf
 
Top Java Frameworks.pdf
Top Java Frameworks.pdfTop Java Frameworks.pdf
Top Java Frameworks.pdf
 
Numpy ndarrays.pdf
Numpy ndarrays.pdfNumpy ndarrays.pdf
Numpy ndarrays.pdf
 
Float Data Type in C.pdf
Float Data Type in C.pdfFloat Data Type in C.pdf
Float Data Type in C.pdf
 
IoT Hardware – The Backbone of Smart Devices.pdf
IoT Hardware – The Backbone of Smart Devices.pdfIoT Hardware – The Backbone of Smart Devices.pdf
IoT Hardware – The Backbone of Smart Devices.pdf
 
Internet of Things – Contiki.pdf
Internet of Things – Contiki.pdfInternet of Things – Contiki.pdf
Internet of Things – Contiki.pdf
 
Java abstract Keyword.pdf
Java abstract Keyword.pdfJava abstract Keyword.pdf
Java abstract Keyword.pdf
 
Node.js with MySQL.pdf
Node.js with MySQL.pdfNode.js with MySQL.pdf
Node.js with MySQL.pdf
 
Collections in Python - Where Data Finds Its Perfect Home.pdf
Collections in Python - Where Data Finds Its Perfect Home.pdfCollections in Python - Where Data Finds Its Perfect Home.pdf
Collections in Python - Where Data Finds Its Perfect Home.pdf
 
File Handling in Java.pdf
File Handling in Java.pdfFile Handling in Java.pdf
File Handling in Java.pdf
 
Types of AI you should know.pdf
Types of AI you should know.pdfTypes of AI you should know.pdf
Types of AI you should know.pdf
 
Streams in Node .pdf
Streams in Node .pdfStreams in Node .pdf
Streams in Node .pdf
 
Annotations in Java with Example.pdf
Annotations in Java with Example.pdfAnnotations in Java with Example.pdf
Annotations in Java with Example.pdf
 
RESTful API in Node.pdf
RESTful API in Node.pdfRESTful API in Node.pdf
RESTful API in Node.pdf
 
Top Cryptocurrency Exchanges of 2023.pdf
Top Cryptocurrency Exchanges of 2023.pdfTop Cryptocurrency Exchanges of 2023.pdf
Top Cryptocurrency Exchanges of 2023.pdf
 
Epic Python Face-Off -Methods vs.pdf
Epic Python Face-Off -Methods vs.pdfEpic Python Face-Off -Methods vs.pdf
Epic Python Face-Off -Methods vs.pdf
 
Django Tutorial_ Let’s take a deep dive into Django’s web framework.pdf
Django Tutorial_ Let’s take a deep dive into Django’s web framework.pdfDjango Tutorial_ Let’s take a deep dive into Django’s web framework.pdf
Django Tutorial_ Let’s take a deep dive into Django’s web framework.pdf
 
Benefits Of IoT Salesforce.pdf
Benefits Of IoT Salesforce.pdfBenefits Of IoT Salesforce.pdf
Benefits Of IoT Salesforce.pdf
 
Epic Python Face-Off -Methods vs. Functions.pdf
Epic Python Face-Off -Methods vs. Functions.pdfEpic Python Face-Off -Methods vs. Functions.pdf
Epic Python Face-Off -Methods vs. Functions.pdf
 
Python Classes_ Empowering Developers, Enabling Breakthroughs.pdf
Python Classes_ Empowering Developers, Enabling Breakthroughs.pdfPython Classes_ Empowering Developers, Enabling Breakthroughs.pdf
Python Classes_ Empowering Developers, Enabling Breakthroughs.pdf
 

Recently uploaded

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsAndrey Dotsenko
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 

Recently uploaded (20)

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 

Java Airline Reservation System – Travel Smarter, Not Harder.pdf

  • 1. Java Airline Reservation System – Travel Smarter, Not Harder Welcome to this project on developing an Airline Reservation System using Java and SQLite! This system will consist of four panels – Reservations, Customers, Flights, and Airports – each of which will have a JTable to display data from the database and an input panel to take input from the user and store it into the database. In this project, we will cover the step-by-step process of designing and implementing this system, including setting up the database, creating the user interface, and integrating the functionality to perform various operations such as adding new reservations, customers, flights, and airports, as well as updating and deleting existing data. International flights are those that operate between two or more countries, typically crossing international boundaries. These flights usually involve longer distances. On the other hand, domestic flights operate within a single country. Domestic flights are typically shorter in duration and do not require passengers to go through customs or immigration procedures. For this we will be creating a toggle button which will allow the users to switch between international and domestic flights in the Reservations panel. This button will update our flight choices to reflect the option we selected using the toggle button. By the end of this project, you will have a working Airline Reservation System that can efficiently manage and store customer information, flight schedules, and
  • 2. reservations, making it an invaluable tool for any airline or travel agency. So let’s get started! About Java Airline Reservation System The objective of this project is to provide a comprehensive guide to developing an Airline Reservation System using Java and SQLite. By the end of this project, you will be able to design and implement a system that can efficiently manage and store customer information, flight schedules, and reservations. Specifically, you will learn how to set up the database, create the user interface with JTables, and integrate the functionality to perform various operations such as adding, updating, and deleting data. This project aims to equip you with the skills and knowledge necessary to develop a fully-functional Airline Reservation System. Prerequisites for Airline Reservation System using Java Before starting with this tutorial, you should have the following prerequisites: ■ Basic knowledge of Java programming language, including object-oriented programming concepts. ■ Understanding of SQL and database concepts. ■ Experience with Eclipse or any other Java Integrated Development Environment (IDE). ■ Basic knowledge of Swing GUI toolkit for building user interfaces. ■ Familiarity with SQLite database management system.
  • 3. Download Java Airline Reservation System Project Please download the source code of Java Airline Reservation System Project from the following link: Java Airline Reservation System Project Code Steps to Create Airline Reservation System using Java Following are the steps for developing the Java Airline Reservation System Project: Step 1: Setting Up the Classes in Eclipse 1. Launch Eclipse and go to “File” > “New” > “Java Project”. 2. Assign a name, such as “Airline Reservation System”. 3. Right-click on the project and select “New” > “Class”. 4. Name the first class, for example, “AirlineReservation”. 5. Repeat steps 3 and 4 to create another class, such as “Database”. Step 2: Adding SQLite to the Project in Eclipse Note: Before moving forward, make sure to have the SQLite JAR file downloaded and saved on your computer. This file can be found on MavenRepository 1. Go to the Project Explorer in Eclipse and right-click on your project. 2. Select “Properties” from the menu. 3. In the Properties window, navigate to “Java Build Path” and click the “Libraries” tab. 4. Click the “Add External JARs” button and find the SQLite JAR file. 5. Choose the JAR file and press “Open”. 6. Click “OK” to close the Properties window.
  • 4. Incorporating SQLite into your Eclipse project is now complete after following the steps outlined above. Step 3: Implementing the Database class with the required methods Below is the complete code for the Database class : package school.FirstCode; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import javax.swing.JComboBox; import javax.swing.table.DefaultTableModel; import org.sqlite.SQLiteDataSource; public class Database { // declaring connection and datasource variables static Connection conn; static SQLiteDataSource ds; // initialize method to initialize the database with all the tables public static void dbInit() { ds = new SQLiteDataSource(); try {
  • 5. ds = new SQLiteDataSource(); ds.setUrl("jdbc:sqlite:AirlineDB.db"); } catch ( Exception e ) { e.printStackTrace(); System.exit(0); } try { conn = ds.getConnection(); Statement statement = conn.createStatement(); // Create the airports table statement.executeUpdate("CREATE TABLE IF NOT EXISTS airports (n" + " id INTEGER PRIMARY KEY,n" + " name TEXT NOT NULL,n" + " city TEXT NOT NULL,n" + " country TEXT NOT NULLn" + ");"); // Create the flights table statement.executeUpdate("CREATE TABLE IF NOT EXISTS flights (n" + " id INTEGER PRIMARY KEY,n" + " departure_airport_id INTEGER NOT NULL,n" + " arrival_airport_id INTEGER NOT NULL,n" + " departure_time TEXT NOT NULL,n" + " arrival_time TEXT NOT NULL,n"
  • 6. + " price DECIMAL(10, 2) NOT NULL,n" + " domestic TEXT NOT NULL CHECK (domestic IN ('yes', 'no')),n" + " CONSTRAINT fk_departure_airportn" + " FOREIGN KEY (departure_airport_id)n" + " REFERENCES airports (id),n" + " CONSTRAINT fk_arrival_airportn" + " FOREIGN KEY (arrival_airport_id)n" + " REFERENCES airports (id)n" + " );n"); // Create the customers table statement.executeUpdate("CREATE TABLE IF NOT EXISTS customers (n" + " id INTEGER PRIMARY KEY,n" + " first_name TEXT NOT NULL,n" + " last_name TEXT NOT NULL,n" + " email TEXT NOT NULL,n" + " phone_number TEXTn" + ");"); // Create the customers table statement.executeUpdate("CREATE TABLE IF NOT EXISTS reservations (n" + " id INTEGER PRIMARY KEY,n" + " customer_id INTEGER NOT NULL,n" + " flight_id INTEGER NOT NULL,n" + " seat_number TEXT NOT NULL,n"
  • 7. + " CONSTRAINT fk_customern" + " FOREIGN KEY (customer_id)n" + " REFERENCES customers (id),n" + " CONSTRAINT fk_flightn" + " FOREIGN KEY (flight_id)n" + " REFERENCES flights (id)n" + ");"); // Closing statement and connection statement.close(); conn.close(); }catch ( SQLException e ) { e.printStackTrace(); System.exit( 0 ); } finally { try { if (conn != null) { conn.close(); } }catch (SQLException e) { System.err.println(e); } }
  • 8. } // Method to get update the reservation table with the data from the database public static void updateReservations(DefaultTableModel model) throws SQLException { model.setRowCount(0); conn = ds.getConnection(); String query = "SELECT * From reservations"; PreparedStatement ps = conn.prepareStatement(query); ResultSet rs = ps.executeQuery(); // Add data to the table model while (rs.next()) { int id = rs.getInt("id"); String customer_id = rs.getString("customer_id"); String flight_id = rs.getString("flight_id"); String seat_number = rs.getString("seat_number"); Object[] row = {id, customer_id, flight_id,seat_number}; model.addRow(row); } rs.close(); ps.close(); conn.close(); } // Method to get update the Flights table with the data from the database public static void updateFlights(DefaultTableModel model) throws SQLException {
  • 9. model.setRowCount(0); conn = ds.getConnection(); String query = "SELECT * From flights"; PreparedStatement ps = conn.prepareStatement(query); ResultSet rs = ps.executeQuery(); // Add data to the table model while (rs.next()) { int id = rs.getInt("id"); int departure_airport = rs.getInt("departure_airport_id"); int arrival_airport = rs.getInt("arrival_airport_id"); String departure_time = rs.getString("departure_time"); String arrival_time = rs.getString("arrival_time"); Float price = rs.getFloat("price"); String domestic = rs.getString("domestic"); Object[] row = {id, departure_airport, arrival_airport,departure_time,arrival_time,price,domestic}; model.addRow(row); } rs.close(); ps.close(); conn.close(); } // Method to get update the Customers table with the data from the database
  • 10. public static void updateCustomers(DefaultTableModel model) throws SQLException { model.setRowCount(0); conn = ds.getConnection(); String query = "SELECT * From customers"; PreparedStatement ps = conn.prepareStatement(query); ResultSet rs = ps.executeQuery(); // Add data to the table model while (rs.next()) { int id = rs.getInt("id"); String first_name = rs.getString("first_name"); String last_name = rs.getString("last_name"); String email = rs.getString("email"); String phone_number = rs.getString("phone_number"); Object[] row = {id, first_name, last_name,email,phone_number}; model.addRow(row); } rs.close(); ps.close(); conn.close(); } // Method to get update the Airports table with the data from the database public static void updateAirports(DefaultTableModel model) throws SQLException { model.setRowCount(0);
  • 11. conn = ds.getConnection(); String query = "SELECT * From airports"; PreparedStatement ps = conn.prepareStatement(query); ResultSet rs = ps.executeQuery(); // Add data to the table model while (rs.next()) { int id = rs.getInt("id"); String name = rs.getString("name"); String city = rs.getString("city"); String country = rs.getString("country"); Object[] row = {id, name, city,country}; model.addRow(row); } rs.close(); ps.close(); conn.close(); } // Method to delete an specific item from a specific table public static void delete(String tableName,String id) throws SQLException { conn = ds.getConnection(); String query = "DELETE FROM "+tableName+" WHERE id = "+id+";"; Statement stmt = conn.createStatement(); stmt.execute(query);
  • 12. stmt.close(); conn.close(); } // Method to update jcomboBoxes with the required field values public static void updateBox(JComboBox<String> cbx,String tableName,String domestic_status) throws SQLException { cbx.removeAllItems(); conn = ds.getConnection(); String query = "SELECT id FROM "+tableName+" WHERE domestic = '"+domestic_status+"';"; PreparedStatement ps = conn.prepareStatement(query); ResultSet rs = ps.executeQuery(); while (rs.next()) { cbx.addItem(rs.getString("id")); } ps.close(); conn.close(); } public static void updateBox(JComboBox<String> cbx,String tableName) throws SQLException { cbx.removeAllItems(); conn = ds.getConnection(); String query = "SELECT id FROM "+tableName+";"; PreparedStatement ps = conn.prepareStatement(query); ResultSet rs = ps.executeQuery();
  • 13. while (rs.next()) { cbx.addItem(rs.getString("id")); } ps.close(); conn.close(); } // Method to add the reservations data into the reservations table public static void addReservation(int id,int custID,int flightID,String seatNum) throws SQLException { conn = ds.getConnection(); PreparedStatement ps =conn.prepareStatement("INSERT INTO " + "reservations(id,customer_id,flight_id,seat_number) " + "VALUES(?,?,?,?)"); ps.setInt(1, id); ps.setInt(2, flightID); ps.setInt(3, custID); ps.setString(4, seatNum); ps.executeUpdate(); ps.close(); conn.close(); } // Method to add the Customer data into the Customers table public static void addCustomer(int id,String first_name,String last_name,String email,String phone) throws SQLException {
  • 14. conn = ds.getConnection(); PreparedStatement ps =conn.prepareStatement("INSERT INTO " + "customers(id,first_name,last_name,email,phone_number) " + "VALUES(?,?,?,?,?)"); ps.setInt(1, id); ps.setString(2, first_name); ps.setString(3, last_name); ps.setString(4, email); ps.setString(5, phone); ps.executeUpdate(); ps.close(); conn.close(); } // Method to add the Flight data into the Flights table public static void addFlight(int id,int departure_ap_id,int arrival_ap_id,String departure_time,String arrival_time,float price,String domestic) throws SQLException { conn = ds.getConnection(); PreparedStatement ps =conn.prepareStatement("INSERT INTO " + "flights(id,departure_airport_id,arrival_airport_id,departure_time,arrival_time,price, domestic) " + "VALUES(?,?,?,?,?,?,?)"); ps.setInt(1, id); ps.setInt(2, departure_ap_id);
  • 15. ps.setInt(3, arrival_ap_id); ps.setString(4, departure_time); ps.setString(5, arrival_time); ps.setFloat(6, price); ps.setString(7,domestic); ps.executeUpdate(); ps.close(); conn.close(); } // Method to add the Airport data into the Airports table public static void addAirport(int id,String name,String city,String country ) throws SQLException { conn = ds.getConnection(); PreparedStatement ps =conn.prepareStatement("INSERT INTO " + "airports(id,name,city,country) " + "VALUES(?,?,?,?)"); ps.setInt(1, id); ps.setString(2, name); ps.setString(3, city); ps.setString(4, country); ps.executeUpdate(); ps.close(); conn.close();
  • 16. } } ■ dbInit() – This function initializes the database by creating tables for airports, flights, customers, and reservations using SQLite queries. ■ updateReservations(DefaultTableModel model) – This function updates the reservations table from the database and sets the data in the given table model. It retrieves all the data from the reservations table and adds them to the table model. ■ updateFlights(DefaultTableModel model) – This function updates the flights table from the database and sets the data in the given table model. It retrieves all the data from the flights table and adds them to the table model. ■ updateCustomers(DefaultTableModel model) – This function updates the customers table from the database and sets the data in the given table model. It retrieves all the data from the customers table and adds them to the table model. ■ updateAirports(DefaultTableModel model) – This function updates the airports table from the database and sets the data in the given model.It retrieves all the data from the Airport table and adds them to the table model. Similarly, there are functions to add data to the database like addFlight,addCustomer, etc. Then there’s a delete function that delete the data from the database by using the id field and the table’s name and lastly, the updateBox function updates the combo boxes with relevant data. All these functions connect to the database using the ds (SQLiteDataSource) object and execute SQL queries to fetch data from the tables. They also use the PreparedStatement object to execute SQL queries with parameters. Once the data is fetched from the tables, it is added to the DefaultTableModel object that is passed as a parameter to these functions. Finally, the connection to the database is closed after executing the queries. Step 3: Implementing the AirlineReservation
  • 17. Below is the complete code for the AirlineReservation class : package school.FirstCode; import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JTabbedPane; import java.awt.BorderLayout; import javax.swing.JPanel; import java.awt.Color; import javax.swing.border.TitledBorder; import javax.swing.table.DefaultTableModel; import javax.swing.border.LineBorder; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.sql.SQLException; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JTextField; import javax.swing.JComboBox; import javax.swing.JButton; import javax.swing.JScrollPane; import javax.swing.JTable;
  • 18. import javax.swing.JToggleButton; public class AirlineReservation { private JFrame frmAirlineReservatoinSystem; private JTextField resIDField; private JTextField seatField; private JTable reservationsTable; private JTextField custIDField; private JTextField firstNamefield; private JTable customerTable; private JTextField lastNameField; private JTextField emailField; private JTextField textField_1; private JTextField airportIDField; private JTextField airportNameField; private JTextField cityField; private JTextField countryField; private JTable airportsTable; private JTextField flightIDField; private JTextField departureTimeField; private JTextField arrivalTimeField; private JTextField priceField; private JTable flightTable; /**
  • 19. * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { Database.dbInit(); AirlineReservation window = new AirlineReservation(); window.frmAirlineReservatoinSystem.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the application. */ public AirlineReservation() { initialize(); } /** * Initialize the contents of the frame.
  • 20. */ private void initialize() { frmAirlineReservatoinSystem = new JFrame(); frmAirlineReservatoinSystem.setTitle("Airline Reservation System"); frmAirlineReservatoinSystem.setBounds(100, 100, 800, 500); frmAirlineReservatoinSystem.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frmAirlineReservatoinSystem.getContentPane().setLayout(new BorderLayout(0, 0)); frmAirlineReservatoinSystem.setResizable(false); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); frmAirlineReservatoinSystem.getContentPane().add(tabbedPane); JPanel reservationsPanel = new JPanel(); tabbedPane.addTab("Reservations", null, reservationsPanel, null); reservationsPanel.setLayout(null); JPanel resInputPanel = new JPanel(); resInputPanel.setBounds(5, 53, 281, 349); resInputPanel.setBorder(new TitledBorder(new LineBorder(new Color(0, 0, 0), 5), "Add Reservation", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0))); resInputPanel.setBackground(new Color(192, 191, 188)); reservationsPanel.add(resInputPanel); resInputPanel.setLayout(new GridLayout(0, 2, 0, 10)); JLabel lblID = new JLabel("ID"); resInputPanel.add(lblID); resIDField = new JTextField();
  • 21. resIDField.setColumns(10); resInputPanel.add(resIDField); JLabel lblSeatNo = new JLabel("Seat Number"); resInputPanel.add(lblSeatNo); seatField = new JTextField(); seatField.setColumns(10); resInputPanel.add(seatField); JLabel lblflightID = new JLabel("Flight ID"); resInputPanel.add(lblflightID); JComboBox<String> flightComboBox = new JComboBox<String>(); resInputPanel.add(flightComboBox); JLabel lblCustID = new JLabel("Customer ID"); resInputPanel.add(lblCustID); JComboBox<String> custComboBox = new JComboBox<String>(); resInputPanel.add(custComboBox); JScrollPane reservationscrollPane = new JScrollPane(); reservationscrollPane.setBounds(295, 53, 500, 349); reservationsPanel.add(reservationscrollPane); String[] reservationColumsNames = {"ID","Customer ID","Flight ID","Seat No."}; DefaultTableModel reservationsModel = new DefaultTableModel(reservationColumsNames,0); reservationsTable = new JTable(); reservationsTable.setModel(reservationsModel); reservationscrollPane.setViewportView(reservationsTable);
  • 22. JButton btnLoadReservations = new JButton("Load"); btnLoadReservations.setBackground(new Color(188,108,37)); btnLoadReservations.setBounds(295, 25, 100, 30); btnLoadReservations.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Database.updateReservations(reservationsModel); } catch (SQLException e1) { e1.printStackTrace(); } } }); reservationsPanel.add(btnLoadReservations); JToggleButton tglbtnDomesticFlights = new JToggleButton("Domestic Flights",true); tglbtnDomesticFlights.setBackground(new Color(188,108,37)); tglbtnDomesticFlights.setBounds(400, 25, 200, 30); tglbtnDomesticFlights.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (tglbtnDomesticFlights.isSelected()) { tglbtnDomesticFlights.setText("Domestic Flights"); try {
  • 23. Database.updateBox(flightComboBox,"flights", "yes"); } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } else { tglbtnDomesticFlights.setText("International Flights"); try { Database.updateBox(flightComboBox,"flights", "no"); } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } }); reservationsPanel.add(tglbtnDomesticFlights); JButton btnaddReservation = new JButton("Add"); btnaddReservation.setBackground(new Color(188, 108, 37)); btnaddReservation.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try {
  • 24. Database.addReservation(Integer.valueOf(resIDField.getText()), Integer.valueOf(custComboBox.getSelectedItem().toString()), Integer.valueOf(flightComboBox.getSelectedItem().toString()), seatField.getText()); Database.updateReservations(reservationsModel); JOptionPane.showMessageDialog(btnaddReservation, "Added successfully","Success",JOptionPane.INFORMATION_MESSAGE); } catch (NumberFormatException e1) { JOptionPane.showMessageDialog(btnaddReservation, "Enter Valid ID","Invalid ID",JOptionPane.INFORMATION_MESSAGE); e1.printStackTrace(); } catch (SQLException e1) { JOptionPane.showMessageDialog(btnaddReservation, "Can't Add","Error",JOptionPane.ERROR_MESSAGE); e1.printStackTrace(); } } }); resInputPanel.add(btnaddReservation); JButton btnRemoveReservation = new JButton("Remove"); btnRemoveReservation.setBackground(new Color(188, 108, 37)); btnRemoveReservation.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) {
  • 25. try { Database.delete("reservations",resIDField.getText()); Database.updateReservations(reservationsModel); JOptionPane.showMessageDialog(btnRemoveReservation, "Deleted","success" ,JOptionPane.INFORMATION_MESSAGE); } catch (SQLException e1) { JOptionPane.showMessageDialog(btnRemoveReservation, "Can't Delete","Error" ,JOptionPane.ERROR_MESSAGE); e1.printStackTrace(); } } }); resInputPanel.add(btnRemoveReservation); JPanel customerPanel = new JPanel(); tabbedPane.addTab("Customers", null, customerPanel, null); customerPanel.setLayout(null); JPanel custInputPanel = new JPanel(); custInputPanel.setBorder(new TitledBorder(new LineBorder(new Color(0, 0, 0), 5), "Add Customers", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0))); custInputPanel.setBackground(new Color(192, 191, 188)); custInputPanel.setBounds(12, 36, 281, 349); customerPanel.add(custInputPanel); custInputPanel.setLayout(new GridLayout(0, 2, 0, 10)); JLabel lblID_1 = new JLabel("ID");
  • 26. custInputPanel.add(lblID_1); custIDField = new JTextField(); custIDField.setColumns(10); custInputPanel.add(custIDField); JLabel lblFirstName = new JLabel("First Name"); custInputPanel.add(lblFirstName); firstNamefield = new JTextField(); firstNamefield.setColumns(10); custInputPanel.add(firstNamefield); JLabel lblLastName = new JLabel("Last Name"); custInputPanel.add(lblLastName); lastNameField = new JTextField(); lastNameField.setColumns(10); custInputPanel.add(lastNameField); JLabel lblEmail = new JLabel("Email"); custInputPanel.add(lblEmail); emailField = new JTextField(); emailField.setColumns(10); custInputPanel.add(emailField); JLabel phoneNumField = new JLabel("Phone no."); custInputPanel.add(phoneNumField); textField_1 = new JTextField(); textField_1.setColumns(10);
  • 27. custInputPanel.add(textField_1); JScrollPane customerscrollPane = new JScrollPane(); customerscrollPane.setBounds(305, 35, 500, 349); customerPanel.add(customerscrollPane); String[] custColumnName = {"ID","First Name","Last Name","Email","Phone"}; DefaultTableModel customerModel = new DefaultTableModel(custColumnName,0); customerTable = new JTable(); customerTable.setModel(customerModel); customerscrollPane.setViewportView(customerTable); JButton btnaddCustomer = new JButton("Add"); btnaddCustomer.setBackground(new Color(188, 108, 37)); btnaddCustomer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Database.addCustomer(Integer.valueOf(custIDField.getText()), firstNamefield.getText(), lastNameField.getText(), emailField.getText(), phoneNumField.getText()); Database.updateCustomers(customerModel); JOptionPane.showMessageDialog(btnaddCustomer, "Added Successfully","success" ,JOptionPane.INFORMATION_MESSAGE);
  • 28. } catch (NumberFormatException e1) { JOptionPane.showMessageDialog(btnaddCustomer, "Enter Valid ID","Invalid ID" ,JOptionPane.ERROR_MESSAGE); e1.printStackTrace(); } catch (SQLException e1) { JOptionPane.showMessageDialog(btnaddCustomer, "Can't add","Error" ,JOptionPane.INFORMATION_MESSAGE); e1.printStackTrace(); } } }); custInputPanel.add(btnaddCustomer); JButton btnRemoveCustomer = new JButton("Remove"); btnRemoveCustomer.setBackground(new Color(188, 108, 37)); btnRemoveCustomer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Database.delete("customers",custIDField.getText()); Database.updateCustomers(customerModel); JOptionPane.showMessageDialog(btnRemoveCustomer, "Deleted","success" ,JOptionPane.INFORMATION_MESSAGE); } catch (SQLException e1) { JOptionPane.showMessageDialog(btnRemoveCustomer, "Can't Delete","Error" ,JOptionPane.ERROR_MESSAGE);
  • 29. e1.printStackTrace(); } } }); custInputPanel.add(btnRemoveCustomer); JButton btnLoadCustomers = new JButton("Load All"); btnLoadCustomers.setBackground(new Color(188, 108, 37)); btnLoadCustomers.setBounds(305, 10, 100, 30); btnLoadCustomers.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Database.updateCustomers(customerModel); } catch (SQLException e1) { e1.printStackTrace(); } } }); customerPanel.add(btnLoadCustomers); JPanel flightsPanel = new JPanel(); tabbedPane.addTab("Flights", null, flightsPanel, null); flightsPanel.setLayout(null); JPanel flightsInputPanel = new JPanel();
  • 30. flightsInputPanel.setBorder(new TitledBorder(new LineBorder(new Color(0, 0, 0), 5), "Add Flights", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0))); flightsInputPanel.setBackground(new Color(192, 191, 188)); flightsInputPanel.setBounds(0, 43, 281, 349); flightsPanel.add(flightsInputPanel); flightsInputPanel.setLayout(new GridLayout(0, 2, 0, 10)); JLabel lblID_1_1 = new JLabel("ID"); flightsInputPanel.add(lblID_1_1); flightIDField = new JTextField(); flightIDField.setColumns(10); flightsInputPanel.add(flightIDField); JLabel departure = new JLabel("Departure Time"); flightsInputPanel.add(departure); departureTimeField = new JTextField(); departureTimeField.setColumns(10); flightsInputPanel.add(departureTimeField); JLabel lblArrival = new JLabel("Arrival Time"); flightsInputPanel.add(lblArrival); arrivalTimeField = new JTextField(); arrivalTimeField.setColumns(10); flightsInputPanel.add(arrivalTimeField); JLabel lblPrice = new JLabel("Price"); flightsInputPanel.add(lblPrice);
  • 31. priceField = new JTextField(); priceField.setColumns(10); flightsInputPanel.add(priceField); JLabel lbldepAirportID = new JLabel("Dep Airport ID"); flightsInputPanel.add(lbldepAirportID); JComboBox<String> depAirportIDComboBox = new JComboBox<String>(); flightsInputPanel.add(depAirportIDComboBox); JLabel lblArrAirportID = new JLabel("Arr Airport ID"); flightsInputPanel.add(lblArrAirportID); JComboBox<String> arrAirportIDComboBox = new JComboBox<String>(); flightsInputPanel.add(arrAirportIDComboBox); JScrollPane flightscrollPane = new JScrollPane(); flightscrollPane.setBounds(290, 43, 500, 349); flightsPanel.add(flightscrollPane); String[] flightColumns = {"Id","Dp. Ap. ID","Arr. Ap. ID","Dp Time","Arr Time","Price","Domestic"}; DefaultTableModel flightModel = new DefaultTableModel(flightColumns,0); flightTable = new JTable(); flightTable.setModel(flightModel); flightscrollPane.setViewportView(flightTable); JLabel lblDomestic = new JLabel("Domestic"); flightsInputPanel.add(lblDomestic); JComboBox<String> arrDomesticBox = new JComboBox<String>();
  • 32. arrDomesticBox.addItem("Yes"); arrDomesticBox.addItem("No"); flightsInputPanel.add(arrDomesticBox); JButton btnaddFlight = new JButton("Add"); btnaddFlight.setBackground(new Color(188, 108, 37)); btnaddFlight.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Database.addFlight( Integer.valueOf(flightIDField.getText()), Integer.valueOf(depAirportIDComboBox.getSelectedItem().toString()), Integer.valueOf(arrAirportIDComboBox.getSelectedItem().toString()), departureTimeField.getText(), arrivalTimeField.getText(), Float.valueOf(priceField.getText()), (String)arrDomesticBox.getSelectedItem()); Database.updateFlights(flightModel); JOptionPane.showMessageDialog(btnaddFlight, "Added Successfully","Success" ,JOptionPane.INFORMATION_MESSAGE); } catch (NumberFormatException e1) { JOptionPane.showMessageDialog(btnaddFlight, "Enter Valid ID/price","Invalid ID/price" ,JOptionPane.ERROR_MESSAGE); e1.printStackTrace(); } catch (SQLException e1) {
  • 33. JOptionPane.showMessageDialog(btnaddFlight, "Can't Add","Error" ,JOptionPane.ERROR_MESSAGE); e1.printStackTrace(); } } }); flightsInputPanel.add(btnaddFlight); JButton btnRemoveFlight = new JButton("Remove"); btnRemoveFlight.setBackground(new Color(188, 108, 37)); btnRemoveFlight.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Database.delete("flights", flightIDField.getText()); Database.updateFlights(flightModel); JOptionPane.showMessageDialog(btnRemoveFlight, "Deleted Successfully","Success" ,JOptionPane.INFORMATION_MESSAGE); } catch (SQLException e1) { JOptionPane.showMessageDialog(btnRemoveFlight, "Can't Delete","Error" ,JOptionPane.ERROR_MESSAGE); e1.printStackTrace(); } } });
  • 34. flightsInputPanel.add(btnRemoveFlight); JButton btnLoadFlights = new JButton("Load All"); btnLoadFlights.setBackground(new Color(188, 108, 37)); btnLoadFlights.setBounds(290, 12, 100, 30); btnLoadFlights.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Database.updateFlights(flightModel); } catch (SQLException e1) { e1.printStackTrace(); } } }); flightsPanel.add(btnLoadFlights); JPanel airportPanel = new JPanel(); tabbedPane.addTab("Airport", null, airportPanel, null); airportPanel.setLayout(null); JPanel airportInputPanel = new JPanel(); airportInputPanel.setBorder(new TitledBorder(new LineBorder(new Color(0, 0, 0), 5), "Add Airport", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0))); airportInputPanel.setBackground(new Color(192, 191, 188)); airportInputPanel.setBounds(0, 40, 281, 349);
  • 35. airportPanel.add(airportInputPanel); airportInputPanel.setLayout(new GridLayout(0, 2, 0, 10)); JLabel lblID_2 = new JLabel("ID"); airportInputPanel.add(lblID_2); airportIDField = new JTextField(); airportIDField.setColumns(10); airportInputPanel.add(airportIDField); JLabel lblairportName = new JLabel("Name"); airportInputPanel.add(lblairportName); airportNameField = new JTextField(); airportNameField.setColumns(10); airportInputPanel.add(airportNameField); JLabel lblCity = new JLabel("City"); airportInputPanel.add(lblCity); cityField = new JTextField(); cityField.setColumns(10); airportInputPanel.add(cityField); JLabel lblCountry = new JLabel("Country"); airportInputPanel.add(lblCountry); countryField = new JTextField(); countryField.setColumns(10); airportInputPanel.add(countryField); JScrollPane airportscrollPane = new JScrollPane();
  • 36. airportscrollPane.setBounds(290, 40, 500, 349); airportPanel.add(airportscrollPane); String[] apModelColumns = {"ID","Name","City","Country"}; DefaultTableModel airportTableModel = new DefaultTableModel(apModelColumns,0); airportsTable = new JTable(); airportscrollPane.setViewportView(airportsTable); airportsTable.setModel(airportTableModel); JButton btnaddAirport = new JButton("Add"); btnaddAirport.setBackground(new Color(188, 108, 37)); btnaddAirport.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Database.addAirport(Integer.valueOf(airportIDField.getText()), airportNameField.getText(), cityField.getText(), countryField.getText()); Database.updateAirports(airportTableModel); JOptionPane.showMessageDialog(btnaddAirport, "Added Successfully","Success" ,JOptionPane.INFORMATION_MESSAGE); } catch (NumberFormatException e1) { JOptionPane.showMessageDialog(btnaddAirport, "Enter Valid ID","Invalid ID" ,JOptionPane.ERROR_MESSAGE); e1.printStackTrace();
  • 37. } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); airportInputPanel.add(btnaddAirport); JButton btnRemoveAirport = new JButton("Remove"); btnRemoveAirport.setBackground(new Color(188, 108, 37)); btnRemoveAirport.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Database.delete("airports", airportIDField.getText()); Database.updateAirports(airportTableModel); JOptionPane.showMessageDialog(btnRemoveAirport, "Successfully Deleted","Success",JOptionPane.INFORMATION_MESSAGE); } catch (SQLException e1) { JOptionPane.showMessageDialog(btnRemoveAirport, "Can't Delete","Error",JOptionPane.ERROR_MESSAGE); e1.printStackTrace(); } } });
  • 38. airportInputPanel.add(btnRemoveAirport); JButton btnLoadAirports = new JButton("Load All"); btnLoadAirports.setBackground(new Color(188, 108, 37)); btnLoadAirports.setBounds(289, 12, 100, 30); btnLoadAirports.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Database.updateAirports(airportTableModel); } catch (SQLException e1) { e1.printStackTrace(); } } }); airportPanel.add(btnLoadAirports); try { Database.updateBox(arrAirportIDComboBox, "airports"); Database.updateBox(depAirportIDComboBox, "airports"); Database.updateBox(flightComboBox, "flights","yes"); Database.updateBox(custComboBox, "customers"); } catch (SQLException e1) { e1.printStackTrace(); }
  • 39. } } Summary This project demonstrates the use of SQLite and JDBC to create and manage a database for an airline reservation system. The project covers the creation of a database, creating tables and establishing relationships between them, adding data to the database, and querying the database to retrieve data. The code includes methods to update tables in the database and retrieve data from them, which are demonstrated through the creation of a GUI that allows the user to view flights, airports, customers, and reservations. The GUI also allows the user to add new flights and customers to the database, as well as create and delete reservations. Overall, this project provides a practical example of using JDBC and SQL to create a database and perform basic CRUD (Create, Read, Update, Delete) operations on it. It also demonstrates the use of a graphical user interface (GUI) to interact with the database, which can make it more accessible to end-users.