How to handle a 32-digit number in Java and PostgreSQL?

I am developing a small tool with JavaFX and a PostgreSQL database. My task now is to process a 32-digit digit. I tried it with Long, but its short / small.

I remember that Postgres grumbled because I did not use the correct data type, so I first ask here before changing all the lines again affected by this problem.

I am not mathematically with this number, but I need to keep zero.

What is your advice? String, BigInteger?

Example Code:

//...
myObject.setSerialNumber(getLongFromDB(rs, "serialnumber"));
//...

private static Long getLongFromDB(ResultSet rs, String column) throws SQLException {
    Long l = rs.getLong(column);
    if (rs.wasNull()) l = null; // because getLong is long not Long, I need to know about null
    return l;
}
+4
source share
2 answers

Oracle/PostgreSQL NUMBER/NUMERIC - Java BigDecimal. ( ). , - , .

, Java Int (s)/Long (s) ID, , int/long " ". JEE NUMBER, . BigDecimal , Long.

+3

char/integer, , .
, , .

0

All Articles