Can't put Double number in BigDecimal variable

后端 未结 2 666
旧巷少年郎
旧巷少年郎 2021-01-27 10:20

I\'m using a Double variable which holds the Item price. That variable is stored in postgresql database under a column of money type. I use setBigDecimal(position,value) SQL fu

2条回答
  •  [愿得一人]
    2021-01-27 10:36

    Obviously priceSpinner.getValue() returns BigDecimal and you're trying to convert it to double and then back to BigDecimal.

    Why don't you just do?

    insertStmt.setBigDecimal(position, (BigDecimal) priceSpinner.getValue());
    

提交回复
热议问题