Database query to JsonArray <p>I´m getting data from a database, the query works in the correct way, but I want to save that data in JsonArray.</p> <pre><code>while(rset.next()){ for(int i=0;i&lt;numeroColumnas;i++){ json.addProperty(key[0], rset.getInt(key[0])); json.addProperty(key[1], rset.getString(key[1])); json.addProperty(key[2], rset.getString(key[2])); json.addProperty(key[3], rset.getInt(key[3])); json.addProperty(key[4], rset.getDouble(key[4])); json.addProperty(key[5], rset.getDouble(key[5])); } ajson.add(json); System.out.println("Cadena JSON:" +ajson.toString()); </code></pre> <p>}</p> <p>This code generates an incorrect output, I get repeat values:</p> <blockquote> <p>Cadena JSON:[{"IDCOORD":1,"HORA":"2012-02-13 07:58:06.146","FECHA":"2012-02-13 >07:58:03","COOR_IDEQUIPO":1,"LATITUD":28.56245,"LONGITUD":-16.7000555}]</p> <p>[{"IDCOORD":2,"HORA":"2012-02-13 07:59:41.881","FECHA":"2012-02-13 >07:59:39","COOR_IDEQUIPO":1,"LATITUD":-4.7152449,"LONGITUD":41.6514567}, {"IDCOORD":2,"HORA":"2012->02-13 07:59:41.881","FECHA":"2012-02-13 >07:59:39","COOR_IDEQUIPO":1,"LATITUD":->4.7152449,"LONGITUD":41.6514567}]</p> </blockquote> <p>I´m pretty sure that I´m doing something wrong on while. Thanks in advance!</p>