title: SpringMVC GetJdbcTemplate() getting value from query
body: <p>I have a function and i would like to extract the vaue from the query i used the getJdbcTemplate and i extract the vaue by passing a string query and an object then accessing the value from the object. I would like to access the value when you actually pass a string. My code is :</p>
  
  <p>Here i use Map but i am not passing an object Map results = getJdbcTemplate().queryForMap(sql, userName) and userName is a String. I would have to use Map but how is this written.</p>
  
  <pre><code>public boolean OfficerExist(Officers officer){
  
  
      try{
  
          logger.debug("About to check if officers existing");
  
          String sql = "SELECT userName FROM crimetrack.tblofficers WHERE userName = ?";
  
          logger.info("User Name Found 1");
  
          * Map&lt;String, Object&gt; results = getJdbcTemplate().queryForMap(sql, userName);
  
          logger.info("User Name Found 2");
  
          String dbUserName = (String)results.get("userName");
  
          logger.info("Checking if officers exist "+sql);
  
          if (dbUserName.equals(userName)) {
  
              logger.info("User Name Exists");
              return true;
  
          }else{
              logger.info("User Name Does NOT Exists");
              return false;
          }
          logger.info("User Name Found 3");
  
          return true;
  
      }catch(Exception e){
  
          logger.info(e.getMessage());
          return false;
      }
  }
  </code></pre>