Question: Can someone help me public class Booking { protected static final String URL = jdbc:derby://localhost:1527/FlightSchedulerDBsfs5208; private static final String USERNAME = java; private static final

Can someone help me

 Can someone help me public class Booking { protected static final

String URL = "jdbc:derby://localhost:1527/FlightSchedulerDBsfs5208"; private static final String USERNAME = "java"; private

public class Booking { protected static final String URL = "jdbc:derby://localhost:1527/FlightSchedulerDBsfs5208"; private static final String USERNAME = "java"; private static final String PASSWORD = "java"; private String flight; private Date date; private WaitList waitlist = new WaitList(); private int seatsBooked;

/** * */ protected static Connection connection; // manages connection private PreparedStatement selectAllPeople; private PreparedStatement selectPeopleByLastName; private PreparedStatement insertNewPerson; private PreparedStatement insertBookings; private PreparedStatement insertBooking; private PreparedStatement getFlightSeats;

public Booking() { super(); try { if(!isTableExisting()) { System.out.println("here"); createTable(); System.out.println("there"); } connection = DriverManager.getConnection(URL, USERNAME, PASSWORD); getFlightSeats = connection.prepareStatement("select count(flight) from Bookings where flight = ? and date = ?"); selectAllPeople = connection.prepareStatement("SELECT * FROM Bookings where flight = ? and date = ?"); selectPeopleByLastName = connection.prepareStatement("SELECT * FROM Flights WHERE Name = ?"); insertNewPerson = connection.prepareStatement("INSERT INTO Flights " +"(flightId,Name,numSeats) " + "VALUES (?, ?, ?)"); insertBookings = connection.prepareStatement("INSERT INTO Bookings " +"(flightId, dayId, customerId) " + "VALUES (?, ?,?)"); insertBooking = connection.prepareStatement("INSERT INTO Bookings " +"(Name,Flight,Date) " + "VALUES (?,?,?)");

} catch (SQLException sqlException) { System.out.println("hello there"); sqlException.printStackTrace(); System.exit(1); } } private static boolean isTableExisting() { try { PreparedStatement s = connection.prepareStatement( "SELECT * FROM Bookings"); s.execute(); return true; } catch (SQLException ex) { return false; } } private void createTable() throws SQLException { PreparedStatement create = connection.prepareStatement( "CREATE TABLE Bookings(" + "bookingId INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1), " + "name VARCHAR(20), " + "flight VARCHAR(20) " + "date DATE " + "PRIMARY KEY(bookingId))"); create.execute(); }

run Exception in thread "main" java. lang .NullPointerException at flightschedulers fs5208. Booking. isTableExisting (Booking ava:76) at flightschedulers fs5208. Booking kinit (Booking ava: 52 at flight schedulersfs5208. FlightSchedulersfs5208.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!