package com; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.List; import net.sf.json.JSONArray; public class BaiduSuggestionUtil { public JSONArray getBaiduRelateWord(String input) throws Exception { List<BaiduSuggestionUtil> list = new ArrayList<BaiduSuggestionUtil>(); Connection conn = null; PreparedStatement smt = null; ResultSet rs = null; JSONArray jsonArray = null; BaiduSuggestionUtil bd=null; try{ String sql = "select * from client_mobile_card where name like ?"; conn = DBUtil.getConnection(); smt = conn.prepareStatement(sql); smt.setString(1, "%"+input+"%"); rs = smt.executeQuery(); while (rs.next()) { bd=new BaiduSuggestionUtil(); bd.setName(rs.getString("name")); list.add(bd); } jsonArray = JSONArray.fromObject(list); }catch(Exception e){ e.printStackTrace(); throw e; }finally{ DBUtil.close(rs, smt, conn); } return jsonArray; } public static void main(String args[]) { try { System.out.println(new BaiduSuggestionUtil().getBaiduRelateWord("王")); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } /** 91 * 百度联想词 92 */ private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } }

chenkaizhen LV1
2021年11月26日
zhj7181 LV1
2021年7月4日
totcom LV1
2021年3月3日
邈话12123 LV9
2020年10月29日
duke最拽 LV3
2020年10月22日
能不能不存在 LV13
2020年5月11日
kangran LV1
2020年4月17日
wanminhang LV12
2020年3月15日
3030617253 LV2
2019年11月30日
时空12580 LV13
2019年1月6日