Good I am trying to put data that are not of type String
in my bd made in netbeans, I need a double
and a int
, but when putting them I get an error, things that do not happen if I do with a String
, I leave here the fragment of my code that needs that:
if(codigo==null){
JOptionPane.showMessageDialog(this,"SELECCIONA Y CARGA ANTES DE GUARDAR");
}
else{
baseDatos bd= new baseDatos();
Connection cn= bd.Conectar();
//combersion de tipos
double precio2= Double.parseDouble(precio.getText());
Integer numdias2= Integer.parseInt(numdias.getText());
try {
PreparedStatement pps= cn.prepareStatement("UPDATE PRESTAMO SET "
+ "PRECIO='"+precio2+"',"
+ "NUMDIAS='"+numdias2+"'"
+ "WHERE NUM_SOCIO= "+codigo);
pps.executeUpdate();
} catch (SQLException ex) {
System.out.println("ERROR AL MODIFICAR ->"+ex);
}
bd.cierraConexion();
cargar(-1);
}
}
String codigo;
Sorry if it's too abstract