boa tarde
estou com uma duvida, estou dando um update na minha tabela mais ela esta atualizando todos meus valores com o mesmo valor (tag)
algume pode me ajudar
public void updateDataBase(Tag tag, Tag tag2) {
try {
Class.forName("org.hsqldb.jdbcDriver");
this.con = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost:9001/evav", "sa", "");
Statement st = null;
st = con.createStatement();
int i = st.executeUpdate("update T_EVAV_VAV set TAG1 = " + tag.getValue()
+ " , TAG2 = " + tag.getValue()
+ " , TAG3 = " + tag.getValue()
+ " , TAG4 = " + tag.getValue()
+ " , TAG5 = " + tag.getValue()
+ " , TAG6 = " + tag.getValue()
+ " , TAG7 = " + tag.getValue()
+ " , TAG8 = " + tag.getValue()
+ " , TAG9 = " + tag.getValue()
+ " , TAG10 = " + tag.getValue()
+ " , TAG11 = " + tag.getValue()
+ " , TAG12 = " + tag.getValue()
+ " , TAG13 = " + tag.getValue()
+ " , TAG14 = " + tag.getValue()
+ " , TAG15 = " + tag.getValue()
+ " , TAG16 = " + tag.getValue()
+ " , TAG17 = " + tag.getValue()
+ " , TAG18 = " + tag.getValue()
+ " , TAG19 = " + tag.getValue()
+ " , TAG20 = " + tag.getValue()
+ " , TAG21 = " + tag.getValue()
+ " , TAG22 = " + tag.getValue()
+ " , TAG23 = " + tag.getValue()
+ " , TAG24 = " + tag.getValue()
);
st.close();
} catch (Exception e) {
System.out.println("Erro de conexão: " + e.getMessage());
}
}
public Connection getConnection() {
return this.con;
}
public void close() {
try {
if (this.con != null)
this.con.close();
} catch (Exception e) {
System.out.println("Erro ao fechar a conexão " + e.getMessage());
}
}
public static void main(String[] args) {
HsqlClient hs = new HsqlClient();
SerialComm serial = new SerialComm();
serial.setPortname("COM1");
serial.setBaudrate(19200);
serial.setDatabits(8);
serial.setParity(0);
serial.setStopbits(1);
serial.setEncoding("rtu");
serial.setEcho(false);
serial.preparePort();
serial.openPort();
ModbusRequest modbus = new ModbusRequest();
Tag tag = new Tag();
tag.setAddress(1);
tag.setFunctionCode(6);
tag.setRegister(264);
tag.setValue(100);
Tag tag2 = new Tag();
tag2.setAddress(1);
tag2.setFunctionCode(6);
tag2.setRegister(257);
tag2.setValue(20);
modbus.runTag(tag, serial.getConnection());
System.out.println("Valor da Tag pelo Modbus: " + tag.getValue());
System.out.println("Valor da Tag 2 pelo Modbus: " + tag2.getValue());
hs.updateDataBase(tag, tag2);
System.out.println(tag);
System.out.println(tag2);
serial.closePort();