Guest User

Untitled

a guest
Nov 5th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. System.out.println(Del_inc);
  2. System.out.println(Del_local);
  3.  
  4. if((Del_inc.equals("#")) && (Del_local.equals("&")) ) { //Se caracteres OK.
  5.  
  6. msg_rec_str = dadoRFID.substring(6, 12); //Pega os prox 6 caracteres apรณs o "#"
  7. loc_est_str = dadoRFID.substring(1,5);
  8. }else {
  9. System.out.println("Nรฃo encontrou");
  10. }
  11.  
  12. System.out.println("MSG"+ msg_rec_str);
  13. System.out.println("teste"+ loc_est_str);
  14. try {
  15.  
  16. Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/sistemarfid?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&useTimezone=true&serverTimezone=UTC", "root", "12345");
  17. Statement statement=con.createStatement();
  18.  
  19. Resultset rs= (Resultset) statement.executeQuery("select from estoque where cod_rfid =" + msg_rec_str);
  20. ((ResultSet) rs).next();
  21. int codrfid = ((ResultSet) rs).getInt(3);
  22.  
  23. Resultset rs2= (Resultset) statement.executeQuery("select from estoque where endereco_estoque =" + loc_est_str);
  24. ((ResultSet) rs2).next();
  25. int localrfid = ((ResultSet) rs2).getInt(4);
  26.  
  27. Resultset rs3= (Resultset) statement.executeQuery("select from estoque where estatus =" + 0);
  28. ((ResultSet) rs3).next();
  29. int estatusrfid = ((ResultSet) rs3).getInt(5);
  30.  
  31.  
  32. String dado_bd = "0"+ codrfid; //Variavel com o
  33. String loc = "0"+localrfid; //Var com o retorno do local do BD
  34. String status_bd = "0"+ estatusrfid;
  35.  
  36. if(loc.equals(loc_est_str)) {
  37. System.out.println("LOCAL CONFIRMADO");
  38. switch (status_bd) { //Faz buscar para trocar
  39. case "0":
  40. System.out.println("status = 1");
  41. String sql1 = "update estoque set estatus = 1";
  42. PreparedStatement stmt = con.prepareStatement(sql1);
  43. stmt.executeUpdate();
  44. //stmt.execute();
  45. stmt.close();
  46.  
  47. con.close();
  48.  
  49. break;
  50. case "1":
  51. System.out.println("status = 2");
  52. String sql2 = "update estoque set estatus = 1";
  53. PreparedStatement stmt2 = con.prepareStatement(sql2);
  54. stmt2.executeUpdate();
  55. //stmt.execute();
  56. stmt2.close();
  57.  
  58. break;
  59. case "2":
  60. System.out.println("status = 1");
  61.  
  62. String sql3 = "update estoque set estatus = 1";
  63. PreparedStatement stmt3 = con.prepareStatement(sql3);
  64. stmt3.executeUpdate();
  65. //stmt.execute();
  66. stmt3.close();
  67.  
  68. break;
  69. default:System.out.println("Status nao confirmado");
  70. break;
  71. }
  72.  
  73. }else {
  74. System.out.println("LOCAL ERRADO");
  75. }
Add Comment
Please, Sign In to add comment