public List<Map<String, Object>> findKColumnsCNVD(int offset, int num, List<Object> params) throws SQLException { String sql = "SELECT * FROM cnvd_net_device LIMIT " + String.valueOf(num) + " OFFSET " + String.valueOf(offset); List<Map<String, Object>> list = jdbcUtils.findSimplesResult(sql, params); Map<String, Object> map = new HashMap<String, Object>(); Date date; DateFormat dataFormat = new SimpleDateFormat("yyyy-MM-dd"); for (int i = 0; i < list.size(); i++) { map = list.get(i); /* * The timestamps of python and Java are different. * Java uses millisecond while python uses seconds. */ String uploadTime = dataFormat.format((int) map.get("modify_time") * 1000.0); String publishTime = dataFormat.format((int) map.get("publish_time") * 1000.0); String modifyTime = dataFormat.format((int) map.get("modify_time") * 1000.0); list.get(i).put("publish_time", publishTime); list.get(i).put("upload_time", uploadTime); list.get(i).put("modify_time", modifyTime); } return list; }
public List<String> findBrands() throws SQLException { String sql = "SELECT distinct threat_rank FROM vulnerability_info.cnvd_net_device"; List<Map<String, Object>> list = jdbcUtils.findSimplesResult(sql, null); List<String> ret = new ArrayList<String>(); for (int i = 0; i < list.size(); i++) { ret.add((String) list.get(i).get("threat_rank")); } return ret; }