首 页       用户登录  |  用户注册
设为首页
加入收藏
联系我们
按字母检索 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
按声母检索 A B C D E F G H J K L M N O P Q R S T W X Y Z 数字 符号
您的位置: 5VAR论文频道论文中心计算机论文计算机应用
   用JAVA制作ICQ      ★★★ 【字体: 】  
用JAVA制作ICQ
收集整理:佚名    来源:本站整理  时间:2009-01-10 11:56:20   点击数:[]    

println(/false/);} System.out.println(/over addnewfriend/); }//end addfriend //结束处理其他用户如果加我,我就加他 //delete friend //以下执行用户删除好友 else if(str.equals(/delfriend/)){ System.out.println(/del/); try{ Class.forName(/sun.jdbc.odbc.JdbcOdbcDriver/); Connection c7=DriverManager.getConnection(/jdbc:odbc:javaicq/,/ /,/ /); //连接数据库,根据接受的用户号码及好友号码向好友表删除记录 int friendicqno=Integer.parseInt(in.readLine()); System.out.println(friendicqno); int myicqno=Integer.parseInt(in.readLine()); System.out.println(myicqno); String addfriend=/delete from friend where icqno=? and friend=?/; PreparedStatement prepare7=c7.prepareCall(addfriend); prepare7.clearParameters(); prepare7.setInt(1,myicqno); prepare7.setInt(2,friendicqno); int r7=0; r7=prepare7.executeUpdate(); if(r7==1) System.out.println(/ok delfrien/);//成功 else System.out.println(/false delfriend/);//失败 }catch (Exception e){e.printStackTrace();System.out.println(/del false/);} }//end delete friend //执行用户删除好友结束 //以下处理用户退出程序 else if(str.equals(/logout/)){ try{ Class.forName(/sun.jdbc.odbc.JdbcOdbcDriver/); Connection c8=DriverManager.getConnection(/jdbc:odbc:javaicq/,/ /,/ /); //连接数据库,根据接受的用户号码,将其状态字段设为0,及ip地址设为空 int myicqno=Integer.parseInt(in.readLine()); System.out.println(myicqno); String status=/update icq set status=0 , ip=' ' where icqno=?/; PreparedStatement prest8=c8.prepareCall(status); prest8.clearParameters(); prest8.setInt(1,myicqno); int r8=prest8.executeUpdate(); if(r8==1) System.out.println(/ok logout/); else System.out.println(/false logout/); }catch (Exception e){e.printStackTrace();System.out.println(/logout false/);} }//logout end //处理用户退出程序结束 //get who add me as friend //以下处理那些人加了我为好友,以便上线通知他们 else if(str.equals(/getwhoaddme/)){ System.out.println(/getwhoaddme/); try{ Class.forName(/sun.jdbc.odbc.JdbcOdbcDriver/); Connection c9=DriverManager.getConnection(/jdbc:odbc:javaicq/,/ /,/ /); //连接数据库,根据我的号码,从好友表中选择谁加了我 int myicqno=Integer.parseInt(in.readLine()); System.out.println(myicqno); String getwhoaddme=/select icqno from friend where friend=?/; PreparedStatement prepare6=c9.prepareCall(getwhoaddme); prepare6.clearParameters(); prepare6.setInt(1,myicqno); ResultSet r6=prepare6.executeQuery(); Vector who=new Vector(); while(r6.next()){ who.add(new Integer(r6.getInt(1))); }//end while //然后告诉这些好友的ip地址,然后发给用户以便告诉其他客户我上线了 for(int i=0;i<who.size();i++){ String whoinfo=/select ip from icq where icqno=? and status=1/; PreparedStatement prepare=c9.prepareCall(whoinfo); prepare.clearParameters(); prepare.setObject(1,who.get(i)); ResultSet r=prepare.executeQuery(); while(r.next()){ out.println(r.getString(/ip/)); } //while r.close(); }//for out.println(/over/); System.out.println(/over/); c9.close();r6.close(); }catch (Exception e){e.printStackTrace();System.out.println(/false/);} }//end get who add me as friend //处理上线结束 System.out.println(/Echo ing :/+str); } System.out.println(/Close.../); }catch(IOException e){}//捕或异常 finally {try{socket.close();} catch(IOException e){} } }} public class Server{//主服务器类 public static void main(String args[])throws IOException{ ServerSocket s=new ServerSocket(8080);//在8080端口创建套接口 System.out.println(/Server start../+s); try{ while(true){Socket socket=s.accept();//无限监听客户的请求 System.out.println(/Connectino accept:/+socket); try{new ServerThread(socket);//创建新线程 }catch(IOException e){socket.close();} } }finally{s.close();}//捕或异常 } }//服务器程序结束

客户程序如下(部分)
客户通过Socket(InetAddress,port)建立与服务器的连接。服务器与客户都通过构造BufferedReader,PrintWriter来建立输入输

上一页  [1] [2] [3] [4] [5] [6]  下一页


Tags:


文章转载请注明来源于:5VAR论文频道 http://paper.5var.com。本站内容整理自互联网,如有问题或合作请Email至:support@5var.com
或联系QQ37750965
提供人:佚名
  • 上一篇文章:Developer/2000中的Forms参数及应用

  • 下一篇文章:基于GP算法的知识发现系统
  • 返回上一页】【打 印】【关闭窗口
    中查找“用JAVA制作ICQ”更多相关内容 5VAR论文频道
    中查找“用JAVA制作ICQ”更多相关内容 5VAR论文频道
    最新热点 最新推荐 相关新闻
  • ››Delphi 5 数据库应用中ODBC数据源的...
  • ››用Visual Basic 6.0实现自动化测试...
  • ››用JAVA制作ICQ
  • ››在IIS 4.0上配置虚拟主机实现虚拟I...
  • ››利用VB开发CAI课件
  • ››基于GP算法的知识发现系统
  • ››基于Client/Server 的课件系统的设...
  • ››WWW对大量数据查询的一种实现
  • ››基于PHP的Web数据库访问
  • ››Developer/2000中的Forms参数及应用...
  • ››用JAVA制作ICQ
  •   文章-网友评论:(评论内容只代表网友观点,与本站立场无关!)
    关于本站 - 网站帮助 - 广告合作 - 下载声明 - 网站地图
    Copyright © 2006-2033 5Var.Com. All Rights Reserved .