Hi,

I'm trying to execute a SQL and store the result in a Json Array.

What would be the most efficient code block??



JSONObject obj = new JSONObject();

while (rs.next()) {

obj.put("NAME", rs.getString("NAME"));

jsonArr.add(obj.clone());

}

* Or*

while (rs.next()) {

obj = new JSONObject();

obj.put("NAME", rs.getString("NAME"));

jsonArr.add(obj);

}

On Fri, Dec 5, 2014 at 11:05 AM, Lahiru Cooray <[email protected]> wrote:

>
> Hi,
>
> I'm trying to execute a SQL and store the result in a Json Array.
>
> What would be the most efficient code block??
>
>
>
>  JSONObject obj = new JSONObject();
>
> while (rs.next()) {
>
> obj.put("NAME", rs.getString("NAME"));
>
> jsonArr.add(obj.clone());
>
> }
>
> * Or*
>
> while (rs.next()) {
>
> JSONObject obj = new JSONObject();
>
> obj.put("NAME", rs.getString("NAME"));
>
> jsonArr.add(obj);
>
> }
>
>
> --
> *Lahiru Cooray*
> Software Engineer
> WSO2, Inc.;http://wso2.com/
> lean.enterprise.middleware
>
> Mobile: +94 715 654154
>



-- 
*Lahiru Cooray*
Software Engineer
WSO2, Inc.;http://wso2.com/
lean.enterprise.middleware

Mobile: +94 715 654154
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to