title: arraylist/list RESTful web service json
body: <p>Hello I want to ask about web service, how to show values from database to Map&lt;>?</p>
  
  <p>here is my code </p>
  
  <pre><code>    @GET
      @Path("/jurusan/{kode_jurusan}")
      @Produces(MediaType.APPLICATION_JSON)    
      public Map getMatkulByjurusan(@PathParam("kode_jurusan") String kode_jurusan){
          Map&lt;String, Object&gt; rs = new HashMap&lt;String, Object&gt;();
          rs.put("Pesan", "Berhasil");
          System.out.println("Jurusan "+kode_jurusan);
          try {
              createConnection();
              MyMap matkul =(MyMap) jt.queryObject("select matkul from tb_matkul where kode_jurusan = ?", new Object[] {kode_jurusan}, new MyMap());
              closeConnection();
              if(matkul != null){
                  rs.put("result", matkul);
              }
          } catch (Exception e) {
              rs.put("Pesan", "Gagal karena : " +e.getMessage());
          }
          return rs;
      }
  
  }
  </code></pre>
  
  <p>but when I try to acess <a href="http://localhost:9090/Service/matkul/jurusan/40" rel="nofollow">http://localhost:9090/Service/matkul/jurusan/40</a> I get the following message:</p>
  
  <pre><code>{"Pesan":"Gagal karena : Incorrect result size: expected 1, actual 14"}
  </code></pre>
  
  <p>this MyMap class</p>
  
  <pre><code>public class MyMap implements Serializable, RowMapper{
      private static final long serialVersionUID = -8840406844877458198L;
      public HashMap&lt;String, Object&gt; map = new HashMap&lt;String, Object&gt;();
  
      public HashMap&lt;String, Object&gt; getMap() {
          return map;
      }
  
      public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
          MyMap dto=new MyMap();
          int rowCount = rs.getMetaData().getColumnCount();
          for (int i = 1; i &lt;= rowCount; i++) {
              dto.map.put(rs.getMetaData().getColumnLabel(i), rs.getObject(i));
          }
          return dto;
      }
  
      public void put(String name, Object o){
          map.put(name, o);
      }
  
      public Object get(String name){
          return map.get(name);
      }
  
      public String getString(String name){
          return (String)map.get(name);
      }
  
      public Integer getInt(String name){
          return (Integer)map.get(name);
      }
  
      public Date getDate(String name){
          return (Date)map.get(name);
      }
  
      public BigDecimal getBigDecimal(String name){
          return (BigDecimal)map.get(name);
      }
  
  
  }
  </code></pre>