java - How to return an ArrayList from a database query? -
I ask the database for a web service using Jersey JX-RS. I can return a line as XML or JSON, but I did not know how to return many records.
Do I use an ArrayList
? if so, how? Does anyone have an example to do this?
- a
roleholder
class that defines all the fields from the table -
Rohnter
with@XmlType
- a
list & lt; Rohilder & gt;
> -@XmlElement
list & lt; ROHOLDER & gt;list & rt; Rohilder & gt; List = new linked list & lt; Rohilder & gt; (); While (rsnext ()) {ROHOLDER holder = new ROHOLDER (); Holder.setName (rs.get ("name")); Holder.setSurname (rs.get ("nickname")); Holder.setEmail (rs.get ("email")); // List for all related fields Add (holder); }
Comments
Post a Comment