Answer to Question #24270 in Java | JSP | JSF for patrick

Question #24270
you have a single aircraft with 40 which flies between New York and London. the first 10 seats a first class while the rest are economy. passengers are required to make bookings for their flights. seats can be reserved and unavailable when paid for. implement the plane as a linked list of seats nodes, in java. seats can be added or removed from the plane as desired. this plane can then be checked if it is empty or full when making a reservation for a customer or if there is a desired seat available. implement an appropriate interface the user or clerk will be using to make these reservations. a reservation should have the traveler's details and the seats reserved and this information needs to be stored persistently. you are required to use a database. i just need the help with communicating with the database. just the explanation please .<br><br>
Expert's answer
First of all you will need a database connector. You canget it from your database's official website. Let's for example use MySQL

You can get the connector here:
You next step will be creating SQL tables for yourentities (bookings), where all the data is represented by plain text (Strings,
numeric types, Date type e.t.c.) The method you execute transactions to
database vary from language to language. Here's a java example:
import java.sql.*;
class Example{
private Connection connection;
public voidinit() {
Properties p =new Properties();
//user and password are set in your db configuration
p.setProperty("user", "root");
p.setProperty("password", "pwd");
try {
} catch (ClassNotFoundException e) {
// TODOAuto-generated catch block
StringconnectionURL = "jdbc:mysql://localhost/yourDatabaseName";
try {
connection= DriverManager.getConnection(connectionURL, p);
} catch(SQLException e) {
// TODOAuto-generated catch block

And that's it. You can use 'connection' object anywhereExecuting SQL statements:

PreparedStatement ps = null;
String sql = "SELECT * FROM userdata WHEREusername=?";
ps =connection.prepareStatement(sql);

That's all the basics

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be the first!

Leave a comment

Ask Your question

New on Blog