title: How to search for a person in a datbase using an API
body: <p>I am writing a HTTP-based RESTful API SMP and I need to write an API that looks up a users with the same handle as the input and returns all the user information, so the entire row. But right now it is not returning anything. I cannot find the problem, any suggestions on what it might be? Thank you for any help!</p>
  
  <pre><code>/api/seeuser        // find a user and give information
  // Input: curl -d '{"handle":"@cooldude42", "password":"mysecret!"}' -H "Content-Type: application/json" -X POST http://localhost:9990/api/seeuser/2 (Links to an external site.)
  // 2 = Identity.idnum
  // Output: {"status":"1", "handle":"@carlos", "fullname":"Carlos Mize", "location":"Kentucky", "email":carlos@notgmail.com", "bdate":"1970-01-26","joined":"2020-04-01"}
  // Output: {}. // no match found, could be blocked, user doesn't know. [EDIT: 04/14]
  // etc.
  </code></pre>
  
  <p>API.java</p>
  
  <pre><code>   @GET
     @Path("/seeuser/{idnum}")
     @Produces(MediaType.APPLICATION_JSON)
     public Response seeuser(@PathParam("idnum") String idnum) {
         String responseString = "{\"status_code\":0}";
         StringBuilder crunchifyBuilder = new StringBuilder();
         try {
             String jsonString = crunchifyBuilder.toString();
             Map&lt;String, String&gt; myMap = gson.fromJson(jsonString, mapType);
             String handle = myMap.get("handle");
             Map&lt;String,String&gt; teamMap = Launcher.dbEngine.seeuser(idnum, handle);
             responseString = Launcher.gson.toJson(teamMap);
         } catch (Exception ex) {
             StringWriter sw = new StringWriter();
             ex.printStackTrace(new PrintWriter(sw));
             String exceptionAsString = sw.toString();
             ex.printStackTrace();
             return Response.status(500).entity(exceptionAsString).build();
         }
         return Response.ok(responseString)
                 .header("Access-Control-Allow-Origin", "*").build();
     }
  </code></pre>
  
  <p>DBEngine.java</p>
  
  <pre><code>public Map&lt;String,String&gt; seeuser(String idnum, String handle) {
         Map&lt;String,String&gt; userIdMap = new HashMap&lt;&gt;();
  
         PreparedStatement stmt = null;
        Integer id = Integer.parseInt(idnum);
         try
         {
             Connection conn = ds.getConnection();
             String queryString = null;
             queryString = "SELECT * FROM Identity WHERE handle = ?";
            stmt = conn.prepareStatement(queryString);
            stmt.setInt(1,id);
  
             ResultSet rs = stmt.executeQuery();
             while (rs.next()) {
                 handle = rs.getString("handle");
                 String pass = rs.getString("pass");
                 String fullname = rs.getString("fullname");
                 String location = rs.getString("location");
                 String email = rs.getString("email");
                 String bdate = rs.getString("bdate");
                 userIdMap.put("handle", handle);
                 userIdMap.put("pass", pass);
                 userIdMap.put("fullname", fullname);
                 userIdMap.put("location", location);
                 userIdMap.put("email", email);
                 userIdMap.put("bdate", bdate);
             }
             rs.close();
             stmt.close();
             conn.close();
         }
         catch(Exception ex)
         {
             ex.printStackTrace();
         }
         return userIdMap;
     }
  </code></pre>