Take the 2-minute tour ×



What is the best datatype to store such object ?

I was thinking about using a Blob to store the binary format of those results (128 bits) ? But I would like to avoid unnecessary type conversions.

share|improve this question
Isn't bigint enough? (is just 8 bytes) –  Octopus-Paul Dec 7 '10 at 9:08
add comment

3 Answers

up vote 3 down vote accepted

I would recommend using a Blob and then the BigInteger(byte[] val) constructor to go from byte array to BigInteger, and the BigInteger#toByteArray() method for the other way.

share|improve this answer
add comment

MySQL has a BIGINT data type as shown in: http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html

You can try to use the BIGINT for that rather then doing conversion to binary formats which makes it whole lot more complex to my opinion.

share|improve this answer
The BIGINT datatype from MySQL can't hold my value ! 2^128 > 18446744073709551615 (max BIGINT unsigned value) ! –  Kami Dec 7 '10 at 9:18
This isn't really BigInteger anymore I guess... it's well more than the specific size of BigInteger. –  thotheolh Dec 7 '10 at 11:40
BigInteger has different meanings in different contexts. The question is tagged "java", where BigInteger means arbitrary precision. –  b0fh Dec 10 '10 at 14:20
add comment
MySQL Type      Java Type
CHAR            String
VARCHAR         String
NUMERIC         java.math.BigDecimal
DECIMAL         java.math.BigDecimal
BIT             boolean
TINYINT         byte
SMALLINT        short
INTEGER         int
BIGINT          long
REAL            float
FLOAT           double
DOUBLE          double
BINARY          byte []
VARBINARY       byte []
DATE            java.sql.Date
TIME            java.sql.Time
TIMESTAMP       java.sql.Tiimestamp


share|improve this answer
Updated - thanks. –  nicc777 Jan 11 '13 at 11:28
add comment

Your Answer


