Advertisement
Guest User

Untitled

a guest
Mar 30th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. public class Client
  2. {
  3. Socket s;
  4. DataOutputStream dos;
  5. DataInputStream dis;
  6. int flag;
  7. public Client() throws IOException
  8. {
  9. try
  10. {
  11. s=new Socket("localhost",1);
  12. dos= new DataOutputStream(s.getOutputStream());
  13. dis= new DataInputStream(s.getInputStream());
  14. OutputStream outputStream = s.getOutputStream();
  15. //clientinfo();
  16. applications();
  17. //Systeminfo();
  18. //ScreenShots();
  19. }
  20. catch(Exception e)
  21. {
  22. System.out.println(e);
  23. }
  24. }
  25.  
  26. public MyServer1() throws IOException
  27. {
  28. ss=new ServerSocket(1);
  29. s=ss.accept();
  30. dis= new DataInputStream(s.getInputStream());
  31. int flag=dis.readInt();
  32. switch(flag)
  33. {
  34. case 1:
  35. {
  36. clientnameip();
  37. break;
  38. }
  39. case 2:
  40. {
  41. processes();
  42. break;
  43. }
  44.  
  45. public void processes()throws IOException
  46. {
  47. int count=dis.readInt();
  48. System.out.print(count);
  49. try
  50. {
  51. Class.forName("com.mysql.jdbc.Driver");
  52. Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/zeeshan","root","sHaNi97426");
  53. Statement stmt=(Statement)conn.createStatement();
  54. for(int i=0;i<count;i++)
  55. {
  56. String app=dis.readUTF();
  57. String insert="INSERT INTO applications VALUES('"+app+"');";
  58. stmt.addBatch(insert);
  59. }
  60. stmt.executeBatch();
  61. }
  62. catch(Exception e)
  63. {
  64. System.out.println(e);
  65. }
  66.  
  67.  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement