I'm doing a project in java netbeans but I can not save the date in my database can you help me thanks this is the code I use:
if(txtgenerico.getText().length()==0
||txtcomercial.getText().length()==0||txtforma.getText().length()==0||txtconcentracion.getText().length()==0||txtcantidad.getText().length()==0||fechavenc.getDate().getDate()==0||txtmarca.getText().length()==0||txtlote.getText().length()==0){
JOptionPane.showMessageDialog(null, "faltan datos por ingresar \n"+"Completelos Todos Por Favor" );
}else{
try{
ResultSet rst;
ConexionBD cc=new ConexionBD();
Statement stmtr;
try (Connection cn = cc.conexion()) {
stmtr = cn.createStatement();
rst = stmtr.executeQuery("SELECT * FROM insumos WHERE generico = '"+txtgenerico.getText()+"'");
if(rst.next()){
JOptionPane.showMessageDialog(null, " Este producto ya existe");
}else{
stmtr.executeUpdate("INSERT INTO insumos (generico, comercial, formafarma, concentracion, cantidad, fechaVenc, marca, numero_lote)"
+ "VALUES ('"+txtgenerico.getText()+"','"+txtcomercial.getText()+"'"
+ ",'"+txtforma.getText()+"','"+txtconcentracion.getText()+"','"+txtcantidad.getText()+"','"+fechavenc.getDate().getDate()+"','"+txtmarca.getText()+"','"+txtlote.getText()+"')");
JOptionPane.showMessageDialog(null, "registro exitoso");
limpiar(); bloquear();
}
}
stmtr.close();
rst.close();
}catch(Exception e){
System.out.printf("Error aqui: "+ e.toString());
}
}
In the MYsql data base, date is a DATE
. Thanks and how to save images in this same language with your route.