import java.sql.*;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Map;

import java.net.URI;
import java.net.URISyntaxException;

import static spark.Spark.*;
import spark.template.freemarker.FreeMarkerEngine;
import spark.ModelAndView;
import static spark.Spark.get;

import static javax.measure.unit.SI.KILOGRAM;
import javax.measure.quantity.Mass;
import org.jscience.physics.model.RelativisticModel;
import org.jscience.physics.amount.Amount;

public class Main {

  public static void main(String[] args) {

    port(Integer.valueOf(System.getenv("PORT")));
    staticFileLocation("/public");

    get("/hello", (req, res) -> {
      RelativisticModel.select();

      String energy = System.getenv().get("ENERGY");

      Amount<Mass> m = Amount.valueOf(energy).to(KILOGRAM);
      return "E=mc^2: " + energy + " = " + m.toString();
    });

    get("/", (request, response) -> {
            Map<String, Object> attributes = new HashMap<>();
            attributes.put("message", "Hello World!");

            return new ModelAndView(attributes, "index.ftl");
        }, new FreeMarkerEngine());

    get("/db", (req, res) -> {
      Connection connection = null;
      Map<String, Object> attributes = new HashMap<>();
      try {
        connection = getConnection();

        Statement stmt = connection.createStatement();
        stmt.executeUpdate("CREATE TABLE IF NOT EXISTS ticks (tick timestamp)");
        stmt.executeUpdate("INSERT INTO ticks VALUES (now())");
        ResultSet rs = stmt.executeQuery("SELECT tick FROM ticks");

        ArrayList<String> output = new ArrayList<String>();
        while (rs.next()) {
          output.add( "Read from DB: " + rs.getTimestamp("tick"));
        }

        attributes.put("results", output);
        return new ModelAndView(attributes, "db.ftl");
      } catch (Exception e) {
        attributes.put("message", "There was an error: " + e);
        return new ModelAndView(attributes, "error.ftl");
      } finally {
        if (connection != null) try{connection.close();} catch(SQLException e){}
      }
  }, new FreeMarkerEngine());

  }

  private static Connection getConnection() throws URISyntaxException, SQLException {
    URI dbUri = new URI(System.getenv("DATABASE_URL"));
    int port = dbUri.getPort();
    String dbUrl = "jdbc:postgresql://" + dbUri.getHost() + ":" + port + dbUri.getPath();

    if (dbUri.getUserInfo() != null) {
      String username = dbUri.getUserInfo().split(":")[0];
      String password = dbUri.getUserInfo().split(":")[1];
      return DriverManager.getConnection(dbUrl, username, password);
    } else {
      return DriverManager.getConnection(dbUrl);
    }
  }

}
@@ -297,177 +297,39 @@
 ort 
-static javax.measure.unit.SI.KILOGRAM;%0Aimport javax.measure.quantity.Mass;%0Aimport org.jscience.physics.model.RelativisticModel;%0Aimport org.jscience.physics.amount.Amount
+com.heroku.sdk.jdbc.DatabaseUrl
 ;%0A%0Ap
@@ -514,221 +514,21 @@
  -%3E 
-%7B%0A      RelativisticModel.select();%0A%0A      String energy = System.getenv().get(%22ENERGY%22);%0A%0A      Amount%3CMass%3E m = Amount.valueOf(energy).to(KILOGRAM);%0A      return %22E=mc%5E2: %22 + energy + %22 = %22 + m.toString();%0A    %7D
+%22Hello World%22
 );%0A%0A
@@ -938,16 +938,38 @@
 ction = 
+DatabaseUrl.extract().
 getConne
@@ -1769,16 +1769,18 @@
       %7D%0A
+  
   %7D, new
@@ -1811,569 +1811,6 @@
  %7D%0A%0A
-  private static Connection getConnection() throws URISyntaxException, SQLException %7B%0A    URI dbUri = new URI(System.getenv(%22DATABASE_URL%22));%0A    int port = dbUri.getPort();%0A    String dbUrl = %22jdbc:postgresql://%22 + dbUri.getHost() + %22:%22 + port + dbUri.getPath();%0A%0A    if (dbUri.getUserInfo() != null) %7B%0A      String username = dbUri.getUserInfo().split(%22:%22)%5B0%5D;%0A      String password = dbUri.getUserInfo().split(%22:%22)%5B1%5D;%0A      return DriverManager.getConnection(dbUrl, username, password);%0A    %7D else %7B%0A      return DriverManager.getConnection(dbUrl);%0A    %7D%0A  %7D%0A%0A
 %7D
+%0A

Update Main.java