title: java.sql.SQLException: No value specified for parameter 2, in a web service
body: <p>I have a problem when trying to make a POST request to a webservice, review the structure of my method in my webservice and my Android method but I did not find the error.</p>
  
  <p>this is my class of Android, my method is called:</p>
  
  <blockquote>
    <p>onClickUpdate (final int position, end String identifier)</p>
  </blockquote>
  
  <pre><code>public class tareasFragmento extends Fragment implements TareasAdapter.OnClickButton{
  
      private String url = "http://192.168.1.128:8080/WebServiceExamenFinal/webapi/tareas";
      private ArrayList&lt;Tareas&gt; listatarea = new ArrayList&lt;&gt;();
  
  
      //Si no funciona esto se puede borrar
  
      AlertDialog alertDialog;
      private List&lt;Tareas&gt; tareasList;
      private TareasAdapter tareasAdapter;
      private int assiId;
  
      public tareasFragmento() {
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
  
          View view = inflater.inflate(R.layout.activity_tareas, container, false);
  
  
          RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recycler_list);
          recyclerView.setHasFixedSize(true);
          recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 2,
                  GridLayoutManager.VERTICAL, false));
  
          final TareasAdapter adapter = new TareasAdapter(getActivity(), listatarea);
          adapter.setCallback(this);
          recyclerView.setAdapter(adapter);
  
          RequestQueue queue = Volley.newRequestQueue(getContext());
          final ProgressDialog dialog = new ProgressDialog(getContext());
          dialog.setMessage("Por favor espere...");
          dialog.show();
          try {
              JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(Request.Method.GET, url,
                      new Response.Listener&lt;JSONArray&gt;() {
                          @Override
                          public void onResponse(JSONArray response) {
                              deserializarJSONArray(response);
                              adapter.notifyDataSetChanged();
                              if (dialog.isShowing()) dialog.dismiss();
                          }
                      },
                      new Response.ErrorListener() {
                          @Override
                          public void onErrorResponse(VolleyError error) {
                              Toast.makeText(getActivity(),
                                      "Error al realizar la petición\n" + error.getMessage(),
                                      Toast.LENGTH_LONG).show();
                              if (dialog.isShowing()) dialog.dismiss();
                          }
                      });
              queue.add(jsonArrayRequest);
          }catch (Exception e) {
              Toast.makeText(getActivity(),"El error es: "+e,Toast.LENGTH_LONG).show();
          }
  
          return view;
      }
  
      public void deserializarJSONArray(JSONArray jsonArray) {
  
          for (int i = 0; i &lt; jsonArray.length(); i++) {
              try {
                  JSONObject item = jsonArray.getJSONObject(i);
                  Tareas tareas = new Tareas();
                  tareas.setId(item.getString("id"));
                  tareas.setNombreTarea(item.getString("nombreUsuario"));
                  tareas.setEstudiante(item.getString("estudiante"));
                  tareas.setNota(item.getString("nota"));
  
                  listatarea.add(tareas);
              } catch (JSONException e) {
                  Toast.makeText(getActivity(), "Error al procesar la respuesta de la petición: " + e,
                          Toast.LENGTH_LONG).show();
              }
          }
      }
  
      @Override
      public void onClickUpdate(final int position, final String identificador) {
          AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
          LayoutInflater inflater = this.getLayoutInflater();
          View MyView = inflater.inflate(R.layout.dialog_signin_updatedonante, null);
  
          final EditText identidad = (EditText)MyView.findViewById(R.id.identificador_tarea);
          final EditText nombre_tarea = (EditText)MyView.findViewById(R.id.nombre_tarea);
          final EditText nota = (EditText)MyView.findViewById(R.id.nota_tarea);
          final EditText estudiante = (EditText)MyView.findViewById(R.id.estudiante_tarea);
          identidad.setEnabled(false);
          identidad.setText(identificador);
  
          final JSONObject jsonObject = new JSONObject();
          try{
              jsonObject.put("nombre_tarea","Ejemplo").put("nota","Ejemplo").put("estudiante", "Ejemplo");
          }catch(JSONException e){
              e.printStackTrace();
          }
  
          final RequestQueue queue = Volley.newRequestQueue(getActivity());
  
          builder.setView(MyView)
                  .setPositiveButton("Registrar", new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int id) {
                          if(nombre_tarea.getText().toString().equals("") || nota.getText().toString().equals("") || estudiante.getText().toString().equals("")){
                              Toast.makeText(getActivity(), "Porfavor llena todos los campos", Toast.LENGTH_LONG ).show();
                          }else{
                              String urlPut = "http://192.168.1.128:8080/WebServiceExamenFinal/webapi/tareas/";
                              JsonObjectRequest request = new JsonObjectRequest(Request.Method.PUT, urlPut + identificador, jsonObject,
                                      new Response.Listener&lt;JSONObject&gt;() {
                                          @Override
                                          public void onResponse(JSONObject response) {
                                              Toast.makeText(getActivity(), "Se envió correctamente", Toast.LENGTH_LONG).show();
                                          }
                                      }, new Response.ErrorListener() {
                                  @Override
                                  public void onErrorResponse(VolleyError error) {
                                      Toast.makeText(getActivity(), "Ocurrió un error al enviar la información", Toast.LENGTH_LONG).show();
                                  }
                              });
  
                              queue.add(request);
                          }
  
  
                      }
                  })
                  .setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int id) {
                          Toast.makeText(getActivity(),"No se actualizo ningun registro", Toast.LENGTH_SHORT).show();
                          alertDialog.dismiss();
                      }
                  });
          alertDialog = builder.create();
          alertDialog.show();
  
      }
  
      @Override
      public void onClickDelete(final int position, final String identificador) {
  
  
          AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
          LayoutInflater inflater = this.getLayoutInflater();
          View MyView = inflater.inflate(R.layout.dialog_signin_deletedonante, null);
  
          RecyclerView recyclerView = (RecyclerView)getView().findViewById(R.id.recycler_list);
          recyclerView.setHasFixedSize(true);
          recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 2,
                  GridLayoutManager.VERTICAL, false));
          final TareasAdapter adapter = new TareasAdapter(getActivity(), listatarea);
          adapter.setCallback(this);
          recyclerView.setAdapter(adapter);
  
          builder.setView(MyView)
                  .setPositiveButton("Eliminar", new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(final DialogInterface dialog, int id) {
  
                          //Toast.makeText(getActivity(),"id: "+ identificador, Toast.LENGTH_SHORT).show();
                          String urlDelete = "http://192.168.1.128:8080/WebServiceExamenFinal/webapi/tareas/";
                          final RequestQueue queue = Volley.newRequestQueue(getActivity());
                          StringRequest request = new StringRequest(Request.Method.DELETE, urlDelete + identificador, new Response.Listener&lt;String&gt;() {
  
                              @Override
                              public void onResponse(String response) {
                                  //Aqui actualizo mi fragmento para que se vean reflejados los cambios, intete usar un notifysetDataChange pero no me
                                  //funciono
                                  tareasFragmento tareas = new tareasFragmento();
                                  android.support.v4.app.FragmentManager manager = getFragmentManager();
                                  manager.beginTransaction().replace(R.id.qwe, tareas).commit();
  
                                  Toast.makeText(getActivity(), "La tarea se eliminó correctamente", Toast.LENGTH_LONG).show();
                              }
                          }, new Response.ErrorListener() {
                              @Override
                              public void onErrorResponse(VolleyError error) {
                                  Toast.makeText(getActivity(), "Ocurrió un error en la petición", Toast.LENGTH_LONG).show();
                              }
                          }){
                              @Override
                              public Map&lt;String, String&gt; getHeaders() throws AuthFailureError {
                                  HashMap&lt;String, String&gt; headers = new HashMap&lt;String, String&gt;();
                                  headers.put("Content-Type", "application/json;charset=utf-8");
                                  return headers;
                              }
                          };
                          queue.add(request);
                          }
                  })
                  .setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int id) {
                          Toast.makeText(getActivity(),"No se ha eliminado la tarea", Toast.LENGTH_SHORT).show();
                          alertDialog.dismiss();
                      }
                  });
          alertDialog = builder.create();
          alertDialog.show();
  
      }
  
  }
  </code></pre>
  
  <p>This is my PUT method in my web Service:</p>
  
  <pre><code> @PUT
      @Path("{id}")
      public void put(@PathParam("id")Integer id, Tareas tareas){
          tareas.setId(id);
          try {
              DaoTareas.getInstance().actualizar(tareas);
          } catch (SQLException ex) {
              Logger.getLogger(TareasResource.class.getName()).log(Level.SEVERE, null, ex);
          }
      }
  </code></pre>
  
  <p>And finally this is the method where I have my query:</p>
  
  <pre><code>@Override
      public void actualizar(Tareas entidad) throws SQLException {
          String query = "UPDATE tareas SET nombre_tarea=?, nota=?, estudiante=? WHERE id = ?";
  
          if (actualizar == null) {
              actualizar = Conexion.getInstance().getCon().prepareStatement(query);
          }
  
          actualizar.setString(1, entidad.getNombreUsuario());
          actualizar.setInt(3, entidad.getId());
  
          actualizar.executeUpdate();
      }
  </code></pre>