Insert an int data in postgresql from java

0

I am developing a billing program, I need to insert a data type int but I get an error this is the line:

Item ite = new Item();
ite.setPrecio(txt_precio.getText());
    
asked by Nicolas Mosquera Espinosa 07.03.2018 в 09:06
source

1 answer

0

The error is in trying to save a String in a Double field.

I leave you information on how to do parseDouble Double

This would be an example

String texto = "22.600"; // example String
double valor = Double.parseDouble(texto);

And with your code would be

double valor = Double.parseDouble(txt_precio.getText());
ite.setPrecio(valor);
    
answered by 08.03.2018 / 14:59
source