Ciao a tutti ho un problema di logica, il codice che segue sintatticamente è corretto perchè compila, pero le ho un problema sulle query. se eseguo programma solo con la prima query scrive tutto nel db alla grande se aggiungo il controllo if (r==Gps)..... queste query non vengono eseguite correttamente, non capisco perchè.
if (idtype.equals("130")) {
conn.setAutoCommit(false);
PreparedStatement pstmt = conn.prepareStatement("INSERT INTO storico(IMEI,id,Lat,Lng,Alt,Gps_time_millis,Current_time_millis,Speed,Direction,States,Nsat,VbatE,VbatI) values (\"" +Imei +"\",?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); // QUERY INSERT
// leggi dati
while (null != (mes = in.readLine())) {
StringTokenizer st = new StringTokenizer(mes, ";");
String token = null;
int i = 1;
while(st.hasMoreElements()){
token = st.nextToken();
pstmt.setString(i++, token);
System.out.println(token);
}
pstmt.executeUpdate();
String states= getStates(mes);
long s = Long.parseLong(states) ;
long r = s & Gps;
System.out.println("STATES "+ states);
System.out.println("risultato and " +r);
if(r == Gps){
PreparedStatement pstmt1=conn.prepareStatement("INSERT INTO storico(Gps)values('Acceso')");
pstmt1.executeUpdate();
}else
{
PreparedStatement pstmt2 = conn.prepareStatement("INSERT INTO storico(Gps)values('Spento')");
pstmt2.executeUpdate();
}
}
conn.commit();