0

I have my database with an decimal(10,2) value.

I need to extract it from the database and add a quantity with java, but I don't get it.

From the database query, the value is 5.50

System.out.println(rsMax.getLong(1));
Long cost = rsMax.getLong(1) + 2;

This prints 5 and cost = 7, it should print 5.50 and cost = 7.50

how should I do it?

user1256477
  • 10,763
  • 7
  • 38
  • 62

1 Answers1

1

Long is an integer. You need the BigDecimal type.

user207421
  • 305,947
  • 44
  • 307
  • 483