手机微博定位功能的设计与实现源代码样本.doc
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 手机 定位 功能 设计 实现 源代码 样本
- 资源描述:
-
资料内容仅供您学习参考,如有不当或者侵权,请联系改正或者删除。 手机微博定位功能的设计与实现 源 程 序 4月19日 Comments.java package bean; public class Comments { public String date; public String content; public String cmtName; public String cmtNo; public Comments(String date, String content, String cmtName, String cmtNo) { this.date = date; this.content = content; this.cmtName = cmtName; this.cmtNo = cmtNo; } } Diary.java package bean; import java.util.ArrayList; public class Diary { public String rid; public String title; public String content; public String u_name; public String time; public String u_email; public ArrayList<Comments> commentList; public void setCommentList(ArrayList<Comments> commentList) { mentList = commentList; } public Diary(String no, String title, String content, String u_name, String u_email, String time, ArrayList<Comments> cmtList) { this.rid = no; this.title = title; this.content = content; this.u_name = u_name; this.u_email = u_email; this.time = time; mentList = cmtList; } public Diary(String no, String title, String content, String u_name, String u_email, String time) { this.rid = no; this.title = title; this.content = content; this.u_name = u_name; this.u_email = u_email; this.time = time; } } HeadInfo.java package bean; public class HeadInfo { public String h_id; public String h_des; public String u_no; public HeadInfo(String h_id, String h_des, String u_no) { this.h_id = h_id; this.h_des = h_des; this.u_no = u_no; } } Location.java package bean; public class Location { private int l_id; private double l_x; private double l_y; private String l_address; /** * @return the l_id */ public int getL_id() { return l_id; } /** * @param l_id * the l_id to set */ public void setL_id(int l_id) { this.l_id = l_id; } /** * @return the l_x */ public double getL_x() { return l_x; } /** * @param l_x * the l_x to set */ public void setL_x(double l_x) { this.l_x = l_x; } /** * @return the l_y */ public double getL_y() { return l_y; } /** * @param l_y * the l_y to set */ public void setL_y(double l_y) { this.l_y = l_y; } /** * @return the l_address */ public String getL_address() { return l_address; } /** * @param l_address * the l_address to set */ public void setL_address(String l_address) { this.l_address = l_address; } } P_Comments.java package bean; public class P_Comments { public String content; public String u_no; public String u_name; public String date; public P_Comments(String content, String uNo, String uName, String date) { this.content = content; u_no = uNo; u_name = uName; this.date = date; } } PhotoInfo.java package bean; public class PhotoInfo { public String p_id; public String p_name; public String p_des; public String x_id; public PhotoInfo(String pId, String pName, String pDes, String xId) { super(); p_id = pId; p_name = pName; p_des = pDes; x_id = xId; } } User.java package bean; public class User { public String u_no; public String u_name; public String u_email; public String u_state; public String h_id; public User() { }; public User(String u_no, String u_name, String u_email, String u_state, String h_id) { this.u_no = u_no; this.u_name = u_name; this.u_state = u_state; this.u_email = u_email; this.h_id = h_id; } public String getU_no() { return u_no; } public void setU_no(String u_no) { this.u_no = u_no; } public String getU_name() { return u_name; } public void setU_name(String u_name) { this.u_name = u_name; } public String getU_email() { return u_email; } public void setU_email(String u_email) { this.u_email = u_email; } public String getU_state() { return u_state; } public void setU_state(String u_state) { this.u_state = u_state; } public String getH_id() { return h_id; } public void setH_id(String h_id) { this.h_id = h_id; } } Visitor.java package bean; public class Visitor { public String v_email; public String v_name; public String h_id; public String v_date; public Visitor(String vEmail, String vName, String hId, String vDate) { this.v_email = vEmail; this.v_name = vName; this.h_id = hId; this.v_date = vDate; } } ConstantUtil.java package dao; public class ConstantUtil { public static final String FEIEND = "friend_max"; // 用于获取friend表当前的最大编号 public static final String DIARY = "diary_max"; // 用于获取diary表当前的最大编号 public static final String ALBUM = "album_max"; // 用于获取album表当前的最大编号 public static final String PHOTO = "photo_max"; // 用于获取photo表的最大编号 public static final String COMMENT = "comment_max"; // 用于获取comment表当前的最大编号 public static final String VISIT = "comment_max"; // 用于获取visit表当前的最大编号 public static final String USER = "user_max"; // 用于获取user表当前的最大编号 public static final String HEAD = "head_max"; // 用于获取user表当前的最大编号 public static final String P_COMMENT = "p_comment_max"; // 用于获取user表当前的最大编号 public static final String LOCATION = "location_max";// 用于获取location表当前的最大编号 public static final String CHAR_ENCODING = "GBK"; // 字符串编码格式 public static final String CONNECTION_OUT = "访问数据库出错, 请稍后重试。"; public static final String LOGIN_FAIL = "用户名或密码无效, 请重新输入。"; public static final String REGISTER_FAIL = "注册失败, 请重试。"; public static final String DIARY_FAIL = "日志更新失败, 请重试。"; public static final String DIARY_SUCCESS = "日志更新成功! "; public static final String DELETE_FAIL = "删除失败, 请重试。"; public static final String DELETE_SUCCESS = "删除成功! "; public static final String UPDATE_STATE_SUCCESS = "心情更新成功! "; public static final String UPDATE_STATE_FAIL = "心情更新失败! "; public static final String CREATE_ALBUM_SUCESS = "相册创立成功! "; public static final String CREATE_ALBUM_FAIL = "相册创立失败! "; public static final String UPLOAD_SIZE_EXCEED = "文件大小超过限制! 请重新选择。( 3M以内) "; public static final String UPLOAD_SUCCESS = "文件上传成功。"; public static final String UPLOAD_FAIL = "文件上传失败。"; public static final int DIARY_ABBR = 8;// 显示的日志字数, 超过则省略 public static void pp(byte[] buf) { System.out.println("================================"); int start = buf.length - 100; for (int i = start; i < buf.length; i++) { System.out.print(buf[i]); } System.out.println("\n================================"); } } DBUtil.java package dao; import static dao.ConstantUtil.ALBUM; import static dao.ConstantUtil.CHAR_ENCODING; import static dao.ConstantUtil.COMMENT; import static dao.ConstantUtil.CONNECTION_OUT; import static dao.ConstantUtil.DELETE_FAIL; import static dao.ConstantUtil.DELETE_SUCCESS; import static dao.ConstantUtil.DIARY; import static dao.ConstantUtil.DIARY_FAIL; import static dao.ConstantUtil.DIARY_SUCCESS; import static dao.ConstantUtil.FEIEND; import static dao.ConstantUtil.HEAD; import static dao.ConstantUtil.LOCATION; import static dao.ConstantUtil.LOGIN_FAIL; import static dao.ConstantUtil.PHOTO; import static dao.ConstantUtil.P_COMMENT; import static dao.ConstantUtil.REGISTER_FAIL; import static dao.ConstantUtil.UPDATE_STATE_FAIL; import static dao.ConstantUtil.UPDATE_STATE_SUCCESS; import static dao.ConstantUtil.USER; import static dao.ConstantUtil.VISIT; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; import .MalformedURLException; import java.sql.Blob; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Statement; import java.util.ArrayList; import javax.imageio.ImageIO; import net.sf.json.JSONObject; import mons.httpclient.HttpClient; import mons.httpclient.HttpStatus; import mons.httpclient.methods.GetMethod; import bean.Comments; import bean.Diary; import bean.HeadInfo; import bean.Location; import bean.P_Comments; import bean.PhotoInfo; import bean.User; import bean.Visitor; public class DBUtil { public static Connection getConnection() { Connection con = null; // 注册JDBC驱动 try { Class.forName("com.mysql.jdbc.Driver").newInstance(); con = DriverManager .getConnection( "jdbc:mysql://localhost:3306/kdwb?useUnicode=true&characterEncoding=utf-8", "root", "123456"); } catch (Exception e) { e.printStackTrace(); } return con; } // 修改并过的某一个表中的最大信息量 public static synchronized int getMax(String table) { int max = -1; Connection con = null; // 声明一个数据库连接 Statement st = null;// 声明一个表示式 ResultSet rs = null;// 声明一个结果集 try { con = getConnection(); // 获取数据库的连接 st = con.createStatement(); // 获取表示式 String sql = "update max set " + table + "=" + table + "+1"; st.executeUpdate(sql); // 执行 SQL rs = st.executeQuery("select " + table + " from max"); // 执行 // SQL, 并获得结果集 if (rs.next()) { max = rs.getInt(1); return max; } } catch (Exception e) { e.printStackTrace(); } finally { try { if (rs != null) { rs.close(); rs = null; } } catch (Exception e) { e.printStackTrace(); } try { if (st != null) { st.close(); st = null; } } catch (Exception e) { e.printStackTrace(); } try { if (con != null) { con.close(); con = null; } } catch (Exception e) { e.printStackTrace(); } } return max; } // 登录验证 public static ArrayList<String> checkLogin(String u_email, String u_pwd) { ArrayList<String> result = new ArrayList<String>(); Connection con = null; // 声明数据库的连接 PreparedStatement ps = null; // 声明表示式 ResultSet rs = null; // 声明一个ResultSet结果集 try { con = getConnection(); //获得数据库连接 if (con == null) { // 如果获得数据库连接为空 result.add(CONNECTION_OUT); //返回信息为: 访问数据库出错, 请稍后重试。 return result; } // 批量处理SQL语句 ps = con.prepareStatement("select u_no,u_name,u_email,u_state,h_id from user where u_email=? and u_pwd=?"); ps.setString(1, u_email); ps.setString(2, u_pwd); rs = ps.executeQuery(); if (rs.next()) { // 在数据库中查找出该用户 for (int i = 1; i <= 5; i++) { result.add(rs.getString(i)); // 将用户添加到结果列表 } } else { // 在数据库中未查找出该用户 result.add(LOGIN_FAIL); // 返回登录失败的信息 } } catch (Exception e) { e.printStackTrace(); } finally { try { if (rs != null) { rs.close(); rs = null; } } catch (Exception e) { e.printStackTrace(); } try { if (ps != null) { ps.close(); ps = null; } } catch (Exception e) { e.printStackTrace(); } try { if (con != null) { con.close(); con = null; } } catch (Exception e) { e.printStackTrace(); } } return result; } // 注册新的用户 public static String registerUser(String u_name, String u_pwd, String u_email, String u_state, String h_id, int l_id) { String result = null; Connection con = null; PreparedStatement ps = null; //创立PreparedStatement对象 try { con = getConnection(); if (con == null) { result = CONNECTION_OUT; return result; } ps = con.prepareStatement("insert into user(u_no,u_name,u_pwd,u_email,u_state,h_id,l_id)" + "values(?,?,?,?,?,?,?)"); String u_no = String.valueOf(getMax(USER)); u_name = new String(u_name.getBytes(), "GBK"); u_state = new String(u_state.getBytes(), "GBK"); int no = Integer.valueOf(u_no); int hid = Integer.valueOf(h_id); ps.setInt(1, no); ps.setString(2, u_name); ps.setString(3, u_pwd); ps.setString(4, u_email); ps.setString(5, u_state); ps.setInt(6, hid); ps.setInt(7, l_id); int count = ps.executeUpdate(); if (count == 1) { result = u_email; } else { result = REGISTER_FAIL; } } catch (Exception e) { e.printStackTrace(); } finally { try { if (ps != null) { ps.close(); ps = null; } } catch (Exception e) { e.printStackTrace(); } try { if (con != null) { con.close(); con = null; } } catch (Exception e) { e.printStackTrace(); } } return result; } // 获得好友列表 public static ArrayList<Object> getFiendList(String u_email) { ArrayList<Object> result = new ArrayList<Object>(); Connection con = null; Statement st = null; ResultSet rs = null; try { con = getConnection(); st = con.createStatement(); String sql = "select user.u_no,user.u_name,user.u_email,user.u_state,user.h_id,location.l_x,location.l_y,location.l_address " + "from user ,friend ,location " + " where location.l_id = user.l_id and user.u_email=friend.u_email_other and friend.u_email_my='" + u_email + "'"; rs = st.executeQuery(sql); while (rs.next()) { User user = new User(); user.setU_no(String.valueOf(rs.getInt(1))); String name = new String(rs.getString(2).getBytes("GBK"), CHAR_ENCODING); user.setU_name(name); user.setU_email(rs.getString(3)); String state = new String(rs.getString(4).getBytes("GBK"), CHAR_ENCODING); user.setU_state(state); user.setH_id(String.valueOf(rs.getInt(5))); result.add(user); Location location = new Location(); location.setL_x(rs.getDouble(6)); location.setL_y(rs.getDouble(7)); String address = new String(rs.getString(8).getBytes("GBK"), CHAR_ENCODING); location.setL_address(address); result.add(location); } } catch (Exception e) { e.printStackTrace(); } finally { try { if (rs != null) { rs.close(); rs = null; } } catch (Exception e) { e.printStackTrace(); } try { if (st != null) { st.close(); st = null; } } catch (Exception e) { e.printStackTrace(); } try { if (con != null) { con.close(); con = null; } } catch (Exception e) { e.printStackTrace(); } } return result; } // 删除好友 public static String deleteFriend(String u_email, String u_noToDelete) { String result = null; Connection con = null; PreparedStatement ps = null; try { con = getConnection(); ps = con.prepareStatement("delete from friend where u_email_my=? and u_email_other=?"); ps.setInt(1, Integer.valueOf(u_email)); ps.setInt(2, Integer.valueOf(u_noToDelete)); int count = ps.executeUpdate(); if (count == 1) {展开阅读全文
咨信网温馨提示:1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:0574-28810668;投诉电话:18658249818。




手机微博定位功能的设计与实现源代码样本.doc



实名认证













自信AI助手
















微信客服
客服QQ
发送邮件
意见反馈



链接地址:https://www.zixin.com.cn/doc/9300914.html