2
The code is all working, the problem is the date, I want to take the date of a jformatedtextfiel ##/##/####### in the case txt_data and send to the bank, I’m in the java basics, I’ve been hooked into this code for days and I searched a lot but I didn’t get a result. Please if anyone can help I appreciate.
con_cliente.conecta();
Date data;
SimpleDateFormat in = new SimpleDateFormat("yyyy-mm-dd");//do sistema para o banco
String dataformatada = in.format(txt_data.getText());
try{
data = in.parse(dataformatada);
String gry = "insert into cadastrodeprocesso (Datadecadastro, Cliente, Classificacao, Usuario) values ('"+
data.getDate()+"','"+
txt_nome.getText()+"','"+
cb_classificacao.getSelectedItem()+"','"+
txt_usuario.getText()+"')";
con_cliente.exeQuery(gry);
JOptionPane.showMessageDialog(null,"Gravado com sucesso!");
} catch(Exception add){
JOptionPane.showMessageDialog(null,"Falha ao gravar o registro " +add);
}
}//area para impossibilitar duplicar cadastros de empresas de mesmo nome
else{
JOptionPane.showMessageDialog(null, "Clique em novo para inserir um novo registro");
return;
}
}
}
Questions: does it give any error, if yes, which one? What kind of field Datecadastro in your table?
– cantoni
I think this has been answered here countless times.
– Maniero
I searched but I couldn’t find it here.
– user28748
the field is of type date,
– user28748