public static Map<String, ArrayList<String>> viewedNews(double train) { Map<String, ArrayList<String>> user_model = null; try { user_model = new HashMap<String, ArrayList<String>>(); int total_news = 0, count = 0, train_end = 0; ResultSet rs = DataGetter.getConceptsNum(); while (rs.next()) { total_news = Integer.parseInt(rs.getString(1)); } train_end = (int) (total_news * train); rs = DataGetter.getViewed(); while (rs.next()) { if (count++ >= train_end) { if (user_model.get(rs.getString(1)) == null) { ArrayList<String> m = new ArrayList<String>(); m.add(rs.getString(2)); user_model.put(rs.getString(1), m); } else { user_model.get(rs.getString(1)).add(rs.getString(2)); } } } } catch (Exception e) { e.printStackTrace(); } return user_model; }
/** news is not train data add to news pool to be recommended */ public static Map<String, ArrayList<String>> getNewsSet(double recom) { Map<String, ArrayList<String>> newsSet = null; int total_news = 0, count = 0, recom_start = 0; try { ResultSet rs = DataGetter.getConceptsNum(); while (rs.next()) { total_news = Integer.parseInt(rs.getString(1)); } recom_start = (int) (total_news * recom); newsSet = new HashMap<String, ArrayList<String>>(); rs = DataGetter.getClusteredNews(); while (rs.next()) { if (count++ >= recom_start) { if (newsSet.get(rs.getString(1)) == null) { ArrayList<String> a = new ArrayList<String>(); a.add(rs.getString(2)); newsSet.put(rs.getString(1), a); } else { newsSet.get(rs.getString(1)).add(rs.getString(2)); } } } } catch (Exception e) { e.printStackTrace(); } return newsSet; }
public void buscarEstudiantes(String buscar) { GestorBD bd = new GestorBD(); bd.getConnection(); ResultSet rs = null; try { rs = bd.consulta( "Select * From `icba`.`estudiante` " + "Where (nombre like '%" + buscar + "%' " + "or apellidoPaterno like '%" + buscar + "%' " + "or apellidoMaterno like '%" + buscar + "%') " + "AND estado = '1'"); } catch (SQLException ex) { Logger.getLogger(getName()).log(Level.SEVERE, null, ex); } limpiarTabla(); modelo.addColumn("ID Estudiante"); modelo.addColumn("Nombre"); modelo.addColumn("Apellido Paterno"); modelo.addColumn("Apellido Materno"); // modelo.addColumn("Estado"); try { // Bucle para cada resultado en la consulta while (rs.next()) { // Se crea un array que será una de las filas de la tabla. Object[] fila = new Object[4]; // Hay tres columnas en la tabla // Se rellena cada posición del array con una de las columnas de la tabla en base de datos. for (int i = 0; i < 4; i++) // if (i!=3) fila[i] = rs.getObject(i + 1); // El primer indice en rs es el 1, no el cero, por eso se suma 1. /*else if ("true".equals(String.valueOf(rs.getObject(17)))) fila[i] = "Activo"; else fila[i] = "Inactivo";*/ modelo.addRow(fila); // Se añade al modelo la fila completa. } } catch (SQLException ex) { System.out.println("Hubo un problema al intentar ingresar lo datos" + ex); } }
public int getOwnCommunityCount(int userid) { ResultSet rs = null; int count = 0; try { d = new Dao(); rs = d.executeQuery("select * from community_details where owner=" + userid); while (rs.next()) { count++; } } catch (SQLException e) { System.out.println("SqlException caught" + e.getMessage()); } finally { d.close(); } return count; }
public static Map<String, Map<String, Double>> loadPreference() { Map<String, Map<String, Double>> user_model = null; try { user_model = new HashMap<String, Map<String, Double>>(); String[] temp, processBytes; ResultSet rs = DataGetter.getPreference(); while (rs.next()) { Map<String, Double> m = new TreeMap<String, Double>(); processBytes = rs.getString(2).split("#"); for (String s : processBytes) { temp = s.split("/"); m.put(temp[0], Double.parseDouble(temp[1])); } user_model.put(rs.getString(1), m); } } catch (Exception e) { e.printStackTrace(); } return user_model; }
public static Map<String, Map<String, Double>> getNewsSample() { Map<String, Map<String, Double>> data = new HashMap<String, Map<String, Double>>(); try { ResultSet rs = DataGetter.getConcepts(); String[] temp, processBytes; while (rs.next()) { Map<String, Double> m = new TreeMap<String, Double>(); processBytes = rs.getString(2).split("#"); for (String s : processBytes) { temp = s.split("/"); if (temp[1].compareTo("unknown") != 0) { m.put(temp[1], Double.parseDouble(temp[3])); } else { m.put(temp[0], Double.parseDouble(temp[3])); } } data.put(rs.getString(1), m); } } catch (Exception e) { e.printStackTrace(); } return data; }
public static Map<String, ArrayList<String>> loadRecommend() { Map<String, ArrayList<String>> recommend = null; try { recommend = new HashMap<String, ArrayList<String>>(); ResultSet rs = DataGetter.getRecommend(); while (rs.next()) { if (recommend.get(rs.getString(1)) == null) { ArrayList<String> a = new ArrayList<String>(); String[] temp = rs.getString(2).split("#"); for (int i = 0; i < temp.length; i++) { a.add(temp[i]); } recommend.put(rs.getString(1), a); } else { recommend.get(rs.getString(1)).add(rs.getString(2)); } } } catch (Exception e) { e.printStackTrace(); } return recommend; }
public static List<GameVo> getGameList(boolean isEn) { List<GameVo> list = new ArrayList<GameVo>(); Connection conn = DBManager.getConnection(); // 创建SQL语句 Statement st = null; try { st = (Statement) conn.createStatement(); String sql = "select * from web_index where isen=false order by sort desc,id"; if (isEn) { sql = "select * from web_index where isen=true order by sort desc,id"; } // 执行语句,返回结果 ResultSet rs = (ResultSet) st.executeQuery(sql); while (rs.next()) { GameVo vo = new GameVo(); vo.id = rs.getInt("id"); vo.sort = rs.getInt("sort"); vo.name = rs.getString("name"); vo.gamesize = rs.getString("gamesize"); vo.gameos = rs.getString("gameos"); vo.updatetime = rs.getString("updatetime"); vo.version = rs.getString("version"); vo.info = rs.getString("info"); vo.bgcolor = rs.getString("bgcolor"); vo.bgimg = rs.getString("bgimg"); vo.bigicon = rs.getString("bigicon"); vo.icon = rs.getString("icon"); vo.downloadurl = rs.getString("downloadurl"); vo.navicon = rs.getString("navicon"); vo.isen = isEn; list.add(vo); } } catch (SQLException e) { e.printStackTrace(); } finally { try { st.close(); st = null; conn.close(); conn = null; } catch (SQLException e) { e.printStackTrace(); } } return list; }
public void assignDSSVTreTT(Map<String, Object> session) { this.conn = new Connect(); Map<String, String> infor_user = (Map<String, String>) session.get("information"); String procedure = "call get_tt_qldvn_dssv_thanh_toan_tre(?);"; CallableStatement pstmt = null; try { pstmt = (CallableStatement) this.conn.getConn().prepareCall(procedure); // pstmt.setInt(1, Integer.parseInt(infor_user.get("8_ID_KHOA"))); setTenKhoa(infor_user.get("6_KHOA")); // Thực thi procedure pstmt.execute(); ResultSet rs = (ResultSet) pstmt.getResultSet(); // Duyệt kết quả ds sv this.dsSVTreTT = new ArrayList<sv_tt_diem_no>(); int stt = 1; while (rs.next()) { // Khi hàng đó không null if (!rs.wasNull()) { sv_tt_diem_no sv = new sv_tt_diem_no(); sv.setStt(stt++); sv.setId_sv(rs.getInt("ID")); sv.setId_hp(rs.getInt("ID_HP")); sv.setMssv(rs.getString("MSSV")); sv.setHo_ten(rs.getString("HO_TEN")); sv.setTen_hp(rs.getString("TEN_MH")); sv.setMa_hp(rs.getString("MA_HP")); sv.setMa_mh(rs.getString("MA_MH")); sv.setSo_tc(rs.getInt("SO_TC")); sv.setHk(rs.getInt("HK")); sv.setNk(rs.getString("NK")); // this.dsSVTreTT.add(sv); } } // Đóng kết nối pstmt.close(); rs.close(); this.conn.Close(); } catch (Exception e) { e.printStackTrace(); } }
public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { ForgotPasswordForm pass_frm = (ForgotPasswordForm) form; UserUtility usermanager = new UserUtility(); Dao d = null; ResultSet rs = null; String target = "failure"; if (form != null) { String emailid = pass_frm.getEmailid(); String password = null; String mobile = null; String provider = null; String name = null; try { d = new Dao(); String str = "SELECT * FROM user_details where Email ='" + emailid + "'"; rs = d.executeQuery(str); if (rs.next()) { password = usermanager.decrypt(rs.getString("Password")); mobile = rs.getString("Mobile"); provider = rs.getString("S_Provider"); name = rs.getString("F_Name"); if (password == null) { System.out.println("Could not Retrive Password"); target = "failure"; } StringBuffer msg = new StringBuffer(); msg.append( "<HTML><HEAD><TITLE>ICE Alert</TITLE></HEAD><BODY><div style='margin: 0px; padding: 0px; font-family: Arial,Helvetica,sans-serif; font-size: 12px;'><div><div><img src='" + ICEEnv.getInstance().getLogo() + "' height=60px width=117px/></div>"); msg.append( "<div style='margin: 0pt auto; padding: 10px; font-size: 15px; font-weight: bold; color: #00688b; background-color: rgb(242, 242, 242);'>Hi " + rs.getString("F_Name") + " " + rs.getString("L_Name") + " ,</div>"); msg.append( "<div style='margin: 0pt auto; padding: 10px; font-size: 13px; color: rgb(23, 149, 196); background-color: rgb(249, 249, 249);'>This is your requested login info. reminder from icealert.net. Below are the username and password for your icealert account.</div>"); msg.append( "<div style='margin: 0pt auto; padding: 10px; font-size: 12px; color: rgb(102, 102, 102); background-color: rgb(255, 255, 255);'>"); msg.append( "<span style='font-weight: bold; color: rgb(255, 102, 0); padding-right: 10px;'> Here is your account info:<br/><br/></span> <div style='margin: 0pt auto; padding: 10px 10px 0pt; font-size: 12px; color: rgb(102, 102, 102); background-color: rgb(255, 255, 255);'>"); msg.append( " <div style='clear: both; padding-bottom: 10px;'><span style='width: 100px; float: left; font-weight: bold; color:red;'>ICEID :</span><span style='color:red'><b>" + rs.getString("iceid") + "</b></span></div>"); msg.append( "<div style='clear: both; padding-bottom: 10px;'><span style='width: 100px; float: left; font-weight: bold; color: rgb(102, 102, 102);'>Username :</span><span>" + rs.getString("Email") + "</span></div><div style='clear: both; padding-bottom: 10px;'><span style='width: 100px; float: left; font-weight: bold; color: rgb(102, 102, 102);'>Password :</span><span>" + password + "</span></div>"); msg.append( "</div><br/><div style='margin: 0pt auto; padding: 0 0px 0px 10px; font-size: 12px; color: rgb(102, 102, 102); background-color: rgb(255, 255, 255);'> <strong>Be informed when it really matters!</strong></div><div style='margin: 0pt auto; padding: 10px; font-size: 12px; color: rgb(102, 102, 102); background-color: rgb(255, 255, 255);' > If you need additional assistance, please contact <a target='_blank' style='color: rgb(255, 102, 0);' href='mailto:" + ICEEnv.getInstance().getSupportEmail() + "'>" + ICEEnv.getInstance().getSupportEmail() + "</a></div><hr color='#7A7A7A'> <div style='margin: 0pt auto; padding: 10px; font-size: 12px; color: rgb(56, 144, 177);'><p style='margin: 0px; padding: 0px; font-size: 12px; color:#00688b;'><strong>Thank you for using ,<a target='_blank' style='color: rgb(255, 102, 0);' href='http://" + ICEEnv.getInstance().getCompany() + "'> " + ICEEnv.getInstance().getCompany() + "</a></strong><br/>The ICE Alert Team </p></div><div style='margin: 0pt auto; padding: 20px 10px 10px 80px; font-size: 11px; color: rgb(153, 153, 153);'>This is a post-only mailing. Replies to this message are not monitored or answered.</div></div></div></BODY></HTML>"); String mailmessage = msg.toString(); String smsmessage = "Hello " + name + " Here is your Account Information - Your Username : "******" Password :"******"icealert Login Reminder Info"; String from = ICEEnv.getInstance().getAdminEmail(); String[] emailList = null; String[] recipientscc = {}, recipientsbcc = {}; if (provider.equalsIgnoreCase("0")) { emailList = new String[1]; emailList[0] = emailid; new IceThread(recipientsbcc, recipientscc, emailList, subject, mailmessage, from) .start(); } else { emailList = new String[1]; emailList[0] = emailid; new IceThread(recipientsbcc, recipientscc, emailList, subject, mailmessage, from) .start(); String emailList1[] = {mobile + provider}; new IceThread(recipientsbcc, recipientscc, emailList1, subject, smsmessage, from) .start(); } d.close(); target = "success"; request.setAttribute("status", "8"); return (mapping.findForward(target)); } else { request.setAttribute("status", "9"); } } catch (SQLException e) { e.printStackTrace(); } } return (mapping.findForward(target)); }
public static Map<String, Map<String, Double>> loadUserNClass(double train) { Map<String, Map<String, Double>> user_model = new HashMap<String, Map<String, Double>>(); int total_news = 0, count = 0, train_end = 0; try { ResultSet rs = DataGetter.getConceptsNum(); while (rs.next()) { total_news = Integer.parseInt(rs.getString(1)); } train_end = (int) (total_news * train); rs = DataGetter.getUserNClass(); while (rs.next()) { if (count++ < train_end) { if (user_model.get(rs.getString(1)) == null) { HashMap<String, Double> m = new HashMap<String, Double>(); m.put(rs.getString(2), 1.0); user_model.put(rs.getString(1), m); } else { HashMap<String, Double> m = (HashMap<String, Double>) user_model.get(rs.getString(1)); if (m.get(rs.getString(2)) == null) { m.put(rs.getString(2), 1.0); } else { m.put(rs.getString(2), m.get(rs.getString(2)) + 1); } } } } } catch (Exception e) { e.printStackTrace(); } return user_model; }