I have a table in an SQL database where the data type of the values is BIGINT (20) and I need to get this data for my logic in Java for processing.
What should be the appropriate data type in java to store the return value of BIGINT (20)?
(I was thinking about using Long, but there is BigInteger also, I can’t figure out which is good or suitable)
It depends on the database server. Java is longalways implemented as 8 bytes, as it is part of the standard.
long
In MSSQL, the type bigintis 8 bytes, so it is perfect.
bigint
BIGINT SQL, , . , , MSSQL, MySQL, Oracle, Postgresql IBM DB2 , 8 ( , DB2 64- ).
Java Long 64 , . longs , BigIntegers, .
Long - perfect mapping for a large Int database