减小字体
增大字体
作者:佚名 来源:本站整理 发布时间:2009-01-10 11:56:20
ection(/jdbc:odbc:
javaicq/,/ /,/ /); //以下连接好友表,返回用户的好友名单 String friend=/select friend from friend where icqno=?/; PreparedStatement prepare4=c4.prepareCall(friend); prepare4.clearParameters(); int icqno=Integer.parseInt(in.readLine()); System.out.println(icqno); prepare4.setInt(1,icqno); ResultSet r4=prepare4.executeQuery(); Vector friendno=new Vector();//该矢量保存好友号码 while(r4.next()){ friendno.add(new Integer(r4.getInt(1))); } //read friend info //以下告诉客户其好友的呢称,号码,ip地址,状态,头像,个人资料等信息 out.println(friendno.size()); for(int i=0;i<friendno.size();i++){ String friendinfo=/select nickname,icqno,ip,status,pic,email,info from icq where icqno=?/; PreparedStatement prepare5=c4.prepareCall(friendinfo); prepare5.clearParameters(); prepare5.setObject(1,friendno.get(i)); ResultSet r5=prepare5.executeQuery(); boolean status; while(r5.next()){ out.println(r5.getString(/nickname/)); out.println(r5.getInt(/icqno/)); out.println(r5.getString(/ip/)); status=r5.getBoolean(/status/); if (status)out.println(/1/); else {out.println(/0/);} out.println(r5.getInt(/pic/)); out.println(r5.getString(/email/)); out.println(r5.getString(/info/)); } //while r5.close();}//for//发送完毕 out.println(/over/); System.out.println(/over/); c4.close();r4.close(); }catch (Exception e){e.printStackTrace();System.out.println(/false/);} //socket.close(); }//end friend //读取好友信息完毕 //以下处理用户添加好友 else if(str.equals(/addfriend/)){ System.out.println(/add/); try{ Class.forName(/sun.jdbc.odbc.JdbcOdbcDriver/); Connection c6=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=/insert into friend values(?,?)/; PreparedStatement prepare6=c6.prepareCall(addfriend); prepare6.clearParameters(); prepare6.setInt(1,myicqno); prepare6.setInt(2,friendicqno); int r6=0; r6=prepare6.executeUpdate(); if(r6==1) System.out.println(/ok addfrien/); else System.out.println(/false addfriend/); }catch (Exception e){e.printStackTrace();System.out.println(/false/);} //socket.close(); System.out.println(/over addfriend/); }//end addfriend //用户添加好友结束 //add new friend who add me //以下处理其他用户如果加我,我就加他 else if(str.equals(/addnewfriend/)){ System.out.println(/add/); try{ Class.forName(/sun.jdbc.odbc.JdbcOdbcDriver/); Connection c6=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=/insert into friend values(?,?)/; PreparedStatement prepare6=c6.prepareCall(addfriend); prepare6.clearParameters(); prepare6.setInt(1,myicqno); prepare6.setInt(2,friendicqno); int r6=0; r6=prepare6.executeUpdate(); if(r6==1) System.out.println(/ok addfrien/); else System.out.println(/false addfriend/); String friendinfo=/select nickname,icqno,ip,status,pic,email,info from icq where icqno=?/; //如果成功,就向用户传递好友的基本信息,比如呢称等 PreparedStatement prepare5=c6.prepareCall(friendinfo); prepare5.clearParameters(); prepare5.setInt(1,friendicqno); ResultSet r5=prepare5.executeQuery(); boolean status; while(r5.next()){ System.out.println(/dsf/); out.println(r5.getString(/nickname/)); out.println(r5.getInt(/icqno/)); out.println(r5.getString(/ip/)); status=r5.getBoolean(/status/); if (status)out.println(/1/); else {out.println(/0/);} out.println(r5.getInt(/pic/)); out.println(r5.getString(/email/)); out.println(r5.getString(/info/)); } //while out.println(/over/); r5.close(); c6.close(); }catch (Exception e){e.printStackTrace();System.out.
上一页 [1] [2] [3] [4] [5] [6] 下一页