-3
I have a JTextField
which is populated from the database as text, would like to save in another BD as int
. Could someone please help me?
My code:
String sql = "INSERT INTO ass_cidade(id_cidade) VALUES(?)";
try {
pst = ConnectDB().prepareStatement(sql);
//CidadeAtendida cidade = (CidadeAtendida) txtCidadesAtendidas.getText();
pst.setString(1, txtCidadesAtendidas.getText());
pst.execute();
JOptionPane.showMessageDialog(null, "Cadastro efetuado com sucesso!", "Cadastro efetuado com sucesso", JOptionPane.INFORMATION_MESSAGE);
} catch (SQLException erro) {
JOptionPane.showMessageDialog(null, erro);
}
This example did not work.
– Daivid
Thank you all For your help, it worked out here.
– Daivid
Mark one of the answers as correct, if any helped you Daivid. Or, if you found the answer yourself, post a reply with the solution.
– Gustavo Cinque