useUnicode=true&characterEncoding=utf-8
https://www.jianshu.com/p/846f02d41c14
jdbc 在操作表情时,set names utf8mb4
Class.forName("com.mysql.jdbc.Driver"); conn = DriverManager.getConnection(URL, USER, PASSWORD); st = conn.createStatement(); PreparedStatement pstmtnames = conn.prepareStatement("set names utf8mb4;"); pstmtnames.execute(); // 点击横切位-wk申请好友30小时 PreparedStatement pstmt = conn.prepareStatement(sql); pstmt.setObject(1, nickName); rs = pstmt.executeQuery(); ResultSetMetaData md = rs.getMetaData(); //获得结果集结构信息,元数据 int columnCount = md.getColumnCount(); //获得列数 while (rs.next()) { Map<String,Object> rowData = new HashMap<String,Object>(); for (int i = 1; i <= columnCount; i++) { rowData.put(md.getColumnLabel(i), rs.getObject(i)); } list.add(rowData); } return list;