Firstly, please use scientific notation for large numbers. It took me a good chunk of time to work out that the number you posted was 1027.
If I understand your question correctly, we can probably leave the database out of it. Am I right in thinking that your question boils down to "I need to store positive integers up to 10^27. What is the smallest data type that will fit this?"
If so, a quick google shows that long
s will definitely fit. BigInteger
and BigDecimal
will both also definitely contain your number, since they're arbitrary precision, but you don't need them, and they'll likely make your code more clunky (due to not being primitives). So unless you specifically need the Bignum functionality and methods, use long
. (And I can't see any reason why you'd use a BigDecimal over BigInteger for inputs that are definitely whole numbers).