All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sql.Expert2Json Maven / Gradle / Ivy

The newest version!
package sql;

import com.alibaba.fastjson.JSONObject;
import org.apache.commons.dbutils.handlers.MapListHandler;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;

public class Expert2Json {
    public static void main(String[] args) throws IOException {
        DbUtilsDruid dbUtil = DbUtilsDruid.getInstance();
        String querySql = "Select * from author";
        List> mapList = (List>) dbUtil.query(querySql, new MapListHandler());
        for (Map map : mapList) {
            JSONObject jsonObject = new JSONObject(map);
            FileUtils.write(new File("author2json.json"), jsonObject.toJSONString() + "\n", "utf-8", true);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy