Simple Converter of Java ResultSet into JSONArray

I am now working on a program to upload Data from SQLite to MySQL database on the server. This is one of the tasks to complete this. I found this function on this blog

Here's your full code :

import org.json.JSONArray;
import org.json.JSONObject;
import java.sql.ResultSet;

public class Convertor {
     * Convert a result set into a JSON Array
     * @param resultSet
     * @return a JSONArray
     * @throws Exception
    public static JSONArray getJSON(ResultSet resultSet)
            throws Exception {
        JSONArray jsonArray = new JSONArray();
        while ( {
            int total_rows = resultSet.getMetaData().getColumnCount();
            JSONObject obj = new JSONObject();
            for (int i = 0; i < total_rows; i++) {
                obj.put(resultSet.getMetaData().getColumnLabel(i + 1)
                        .toLowerCase(), resultSet.getObject(i + 1));
        return jsonArray;

Popular posts from this blog

npm refusing to install as a dependency of itself

How to call javascript functions from VB.NET and using WebBrowser Control