Q1.
Search by Aircraft Manufacturer
Neeraja has booked the airplane and she is interested in exploring the things. So she
tries to know the models that are provided by the Aircraft manufacturer.
Given the manufacturer name, list the models provided by them.
[Note: Strictly adhere to the object-oriented specifications given as a part of the
problem statement. Follow the naming conventions as mentioned. Create
separate classes in separate files.]
Create a class AircraftManufacturer with the following attributes.
Data Type Variable name
Integer aircraftManufacturerId
String name
Include appropirate getters, setters, default and parameterized constructors for the
above class
Create a class Aircraft with the following attributes.
Data Type Variable name
Integer aircraftId
AircraftManufacturer aircraftManufacturerInstance
String model
Include appropirate getters, setters, default and parameterized constructors for the
above class
Create a class AircraftDAO with the following method.
Method Name Description
display searchedModels(String This method is used to display the list of models manufactured
name) by the given manufacturer.
Create a class DBConnection with following method.
Method Name Description
This method is used to connect the java application with oracle
public static
database. Here register the JDBC driver for the application,
Connection
configure the database properties(fetch from oracle.properties)
getConnection()
and return the connection object.
Create a class Main with main method and call the method searchedModels(String
name) using AircraftDAO instance to display the list as shown.
oracle.properties :
db.url = jdbc:oracle:thin:@localhost:1521:xe
db.username = root
db.password = student
Use the below code to retrieve the connection details from
oracle.properties to establish connection
ResourceBundle rb = ResourceBundle.getBundle("oracle");
String url = rb.getString("db.url");
String user = rb.getString("db.username");
String pass = rb.getString("db.password");
Table Properties:
create table aircraft_manufacturer(
aircraft_manufacturer_id number(10) not null,
name VARCHAR2(45) not null,
primary key(aircraft_manufacturer_id)
);
create table aircraft(
aircraft_id number(10) not null,
aircraft_manufacturer_id number(10) not null,
model VARCHAR2(45) not null,
primary key(aircraft_id),
foreign key(aircraft_manufacturer_id)
references aircraft_manufacturer(aircraft_manufacturer_id)
);
Download the oracle jar file in the below link.
Oracle jar
[All Texts in bold corresponds to the input and rest are output]
Sample Input and Output 1:
Enter the Aircraft manufacturer :
Airbus
The models provided by Airbus are :
Toulouse A320
Hamburg A319
Seville A400M
Sample Input and Output 2:
Enter the Aircraft manufacturer :
Boeing
The models provided by Boeing are :
Boeing 777
Boeing 767
Q2. Update details of Travel Classes
Write a java program to update the details of Travel class available in the database and
display the list of travel class details in the descending order of names using JDBC
drivers.
[Note: Strictly adhere to the object-oriented specifications given as a part of the
problem statement. Follow the naming conventions as mentioned. Create
separate classes in separate files.]
Create a class TravelClass with the following attributes.
Data Type Variable Name
String name
String description
Include appropirate getters, setters, default and parameterized constructors for the
above class
Create a class TravelClassDAO with a following method
Method name Description
This method retrieves the list of travel classes available in the
void displayTravelClassess() database in the descending order of the travel class name and
displays the same in table format
void updateDetail(String name, This method update the given description into the database for
String description) the given travel class name.
Create a class DBConnection with following method.
Method name Description
This method is used to connect the java application with oracle
public static
database. Here register the JDBC driver for the application,
Connection
configure the database properties(fetch from oracle.properties)
getConnection()
and return the connection object.
Create a class Main with main method and call the methods of TravelClassDAO to
update and display the list as shown.
Use the below format to print the details in table :
System.out.format("%-25s %s\n","Name","Description");
oracle.properties :
db.url = jdbc:oracle:thin:@localhost:1521:xe
db.username = root
db.password = student
Use the below code to retrieve the connection details from
oracle.properties to establish connection
ResourceBundle rb = ResourceBundle.getBundle("oracle");
String url = rb.getString("db.url");
String user = rb.getString("db.username");
String pass = rb.getString("db.password");
Table Properties:
create table travel_class(
id number(10) not null,
name VARCHAR2(45) not null,
description CLOB not null,
primary key(id)
);
Sample Input and Output:
Enter the name of TravelClass :
Economy Class
Enter the description to update :
Lowest travel class of seating in flight travel.
Updated List of Travel Classes
Name Description
Premium Economy Class Positioning in price, comfort, and amenities, this travel
class is leveled between economy class and business class.
Economy Class Lowest travel class of seating in flight travel.
Business Class Intermediate level of service between economy class and first
class.