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?

  1. a roleholder class that defines all the fields from the table
  2. Rohnter with @XmlType
  3. a list & lt; Rohilder & gt; with the @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

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -