Browse Source

Now passing both tests

primary
Kervin Sam 5 years ago
parent
commit
3a3ae9189c
1 changed files with 3 additions and 3 deletions
  1. +3
    -3
      PA2.java

+ 3
- 3
PA2.java View File

@@ -40,7 +40,7 @@ public class PA2 {
+ "GROUP BY Airline "
+ "ORDER BY Count;");
rs.next();
int maxStops = rs.getInt("Count");
int maxStops = rs.getInt("Count") + 2;
System.out.println("The maximum number of stops for any airline is: " + maxStops);
// Copy over all direct flights
@@ -52,11 +52,11 @@ public class PA2 {
+ "SELECT c.Airline, c.Origin, f.Destination, ? as Stops FROM Connected c, Flight f "
+ "WHERE c.Stops = ? AND c.Airline = f.Airline AND c.Destination = f.Origin AND c.Origin <> f.Destination AND NOT EXISTS"
+ " (SELECT * FROM Connected ci "
+ " WHERE c.Airline = ci.Airline AND c.Origin = ci.Origin AND c.Destination = ci.Destination) "
+ " WHERE c.Airline = ci.Airline AND c.Origin = ci.Origin AND ci.Destination = f.Destination) "
+ "GROUP BY c.Airline, c.Origin, f.Destination;");
// Loop through the connecting flights
for (int i = 0; i < 20; i++) {
for (int i = 0; i < maxStops; i++) {
ps.setInt(1, i + 1);
ps.setInt(2, i);
ps.executeUpdate();


Loading…
Cancel
Save