Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- System.out.println(Del_inc);
- System.out.println(Del_local);
- if((Del_inc.equals("#")) && (Del_local.equals("&")) ) { //Se caracteres OK.
- msg_rec_str = dadoRFID.substring(6, 12); //Pega os prox 6 caracteres apรณs o "#"
- loc_est_str = dadoRFID.substring(1,5);
- }else {
- System.out.println("Nรฃo encontrou");
- }
- System.out.println("MSG"+ msg_rec_str);
- System.out.println("teste"+ loc_est_str);
- try {
- Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/sistemarfid?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&useTimezone=true&serverTimezone=UTC", "root", "12345");
- Statement statement=con.createStatement();
- Resultset rs= (Resultset) statement.executeQuery("select from estoque where cod_rfid =" + msg_rec_str);
- ((ResultSet) rs).next();
- int codrfid = ((ResultSet) rs).getInt(3);
- Resultset rs2= (Resultset) statement.executeQuery("select from estoque where endereco_estoque =" + loc_est_str);
- ((ResultSet) rs2).next();
- int localrfid = ((ResultSet) rs2).getInt(4);
- Resultset rs3= (Resultset) statement.executeQuery("select from estoque where estatus =" + 0);
- ((ResultSet) rs3).next();
- int estatusrfid = ((ResultSet) rs3).getInt(5);
- String dado_bd = "0"+ codrfid; //Variavel com o
- String loc = "0"+localrfid; //Var com o retorno do local do BD
- String status_bd = "0"+ estatusrfid;
- if(loc.equals(loc_est_str)) {
- System.out.println("LOCAL CONFIRMADO");
- switch (status_bd) { //Faz buscar para trocar
- case "0":
- System.out.println("status = 1");
- String sql1 = "update estoque set estatus = 1";
- PreparedStatement stmt = con.prepareStatement(sql1);
- stmt.executeUpdate();
- //stmt.execute();
- stmt.close();
- con.close();
- break;
- case "1":
- System.out.println("status = 2");
- String sql2 = "update estoque set estatus = 1";
- PreparedStatement stmt2 = con.prepareStatement(sql2);
- stmt2.executeUpdate();
- //stmt.execute();
- stmt2.close();
- break;
- case "2":
- System.out.println("status = 1");
- String sql3 = "update estoque set estatus = 1";
- PreparedStatement stmt3 = con.prepareStatement(sql3);
- stmt3.executeUpdate();
- //stmt.execute();
- stmt3.close();
- break;
- default:System.out.println("Status nao confirmado");
- break;
- }
- }else {
- System.out.println("LOCAL ERRADO");
- }
Add Comment
Please, Sign In to add comment