title: DELETE, UPDATE a single record in mysql using playframework
body: <p>Hi I am new to Play framework.I would like to implement CRUD operation using MYSQL database in play framework.  </p>
  
  <p>i have able to successfully delete, update the entire table, but not able to successfully delete the single record.  I want to pass the values from html.</p>
  
  <pre><code>index.scala.html
  
  @(message: String)
  
  @main("Welcome to Play") {
  
   &lt;ul id="bars"&gt;
  
      &lt;/ul&gt;
  
  &lt;form action="@routes.Application.addBar()" method="post"&gt;
      &lt;label for="name"&gt; Enter Your name&lt;/label&gt;  &lt;input name="name"/&gt; &lt;br&gt;
      &lt;label for="place"&gt; Enter Your place&lt;/label&gt;  &lt;input name="place"/&gt; &lt;br&gt;
      &lt;input type="submit"/&gt;
  &lt;/form&gt;
  
  &lt;form action="@routes.Application.getBars()" method="get"&gt;
      &lt;label for="retrieve"&gt; Retrieve the details from table &lt;/label&gt;
        &lt;input type="submit"/&gt;
  &lt;/form&gt;
  
  &lt;form action="@routes.Application.deleteBars()" method="get"&gt;
      &lt;label for="Delete"&gt; Delete all the details from table &lt;/label&gt;
        &lt;input type="submit"/&gt;
  &lt;/form&gt;
  
  &lt;form action="@routes.Application.updateBar()" method="post"&gt;
      &lt;label for="name"&gt; Enter Your name&lt;/label&gt;  &lt;input  name="name"/&gt; &lt;br&gt;
      &lt;label for="place"&gt; Enter Your place&lt;/label&gt;  &lt;input name="place"/&gt; &lt;br&gt;
      &lt;input type="submit"/&gt;
  &lt;/form&gt;
  }
  </code></pre>
  
  <p>Application.java    </p>
  
  <pre><code>package controllers;
  
  import com.avaje.ebean.Ebean;
  import com.avaje.ebean.SqlUpdate;
  import java.util.List;
  import models.Bar;
  import play.*;
  import play.data.Form;
  import play.db.ebean.Model;
  import play.mvc.*;
  import play.twirl.api.Content;
  import views.html.*;
  import play.libs.Json;
  public class Application extends Controller {
  
      public static Result index() {
          int rowCount1 = Bar.find.findRowCount();
  
          return ok(index.render("Your new application is ready."));
      }
  
      public static Result addBar() {
          Bar bar = Form.form(Bar.class).bindFromRequest().get();
          bar.save();
          return redirect(routes.Application.index());
      }
  
      public static Result Login() { 
          Bar bar = Form.form(Bar.class).bindFromRequest().get();
          bar.save();
          return redirect(routes.Application.index());
      }
      public static Result getBars(){
          List&lt;Bar&gt; bars = new Model.Finder(String.class, Bar.class).all();
          return ok(Json.toJson(bars));
      }
  
      public static Result deleteBars() {
      SqlUpdate down = Ebean.createSqlUpdate("DELETE FROM bar");
      down.execute(); 
      return redirect(routes.Application.index());
      }
  
      public static Result updateBar() {
  
      SqlUpdate down = Ebean.createSqlUpdate("UPDATE bar SET place = 'asa'");
      down.execute(); 
      return ok();
      }    
  
  }
  </code></pre>
  
  <p>route is as below:</p>
  
  <pre><code>GET     /                           controllers.Application.index()
  POST    /bars2                      controllers.Application.addBar()
  GET     /bars                       controllers.Application.getBars()
  GET     /bars1                      controllers.Application.deleteBars()
  POST     /updateBar/                controllers.Application.updateBar()
  GET     /updateBar1/                controllers.Application.Login()
  
  # Map static resources from the /public folder to the /assets URL path
  GET     /assets/*file               controllers.Assets.at(path="/public", file)
  </code></pre>
  
  <p>What i would like to do is:</p>
  
  <ol>
  <li>Passing the name from HTML for Delete, so that i can delete the record.</li>
  <li>Passing the name, place from HTML for updating.</li>
  </ol>