diff --git a/src/main/java/krusty/Database.java b/src/main/java/krusty/Database.java index b46f9ee..a9a7cac 100644 --- a/src/main/java/krusty/Database.java +++ b/src/main/java/krusty/Database.java @@ -1,15 +1,14 @@ package krusty; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + import spark.Request; import spark.Response; -import java.util.Arrays; -import java.util.Map; -import java.util.TreeMap; -import java.sql.*; - -import static krusty.Jsonizer.toJson; - public class Database { /** * Modify it to fit your environment and then use this string when connecting to your database! @@ -67,7 +66,10 @@ public class Database { } public String getRecipes(Request req, Response res) { - return "{}"; + String query = "Select c.name, i.name, r.amount, i.unit FROM Cookie c, Ingredient i, Recipe r WHERE r.cookie_id = c.cookie_id AND r.ingredient_id = i.ingredient_id;"; + String title = "recipes"; + + return getJson(query, title); } public String getPallets(Request req, Response res) {