Hallo ich möchte über Web-Service fragen, wie Werte von der Datenbank zu Karte < anzeigen>?Arraylist/Liste RESTful Web Service JSON
hier ist mein Code
@GET
@Path("/jurusan/{kode_jurusan}")
@Produces(MediaType.APPLICATION_JSON)
public Map getMatkulByjurusan(@PathParam("kode_jurusan") String kode_jurusan){
Map<String, Object> rs = new HashMap<String, Object>();
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;
}
}
aber wenn ich versuche http://localhost:9090/Service/matkul/jurusan/40 ich folgende Meldung Acess:
{"Pesan":"Gagal karena : Incorrect result size: expected 1, actual 14"}
diese MyMap Klasse
public class MyMap implements Serializable, RowMapper{
private static final long serialVersionUID = -8840406844877458198L;
public HashMap<String, Object> map = new HashMap<String, Object>();
public HashMap<String, Object> 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 <= 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);
}
}
hallo Nein, können Sie sagen, was falsch in meiner MyMap-Klasse ist? Thks – greolaster