how to store BigInteger values in oracle database

拈花ヽ惹草 提交于 2019-12-01 05:25:46

I'm not answering directly your question, but i only see one oracle datatype that can store a 512 bits number : varchar2(156) (156 = abs(log(2^512))+2)

So i would rather convert the biginteger to a string rather than a bigdecimal.

Both BigInteger and BigDecimal extend java.lang.Number, however this does not mean that you can cast from BigInteger up to Number then down to BigDecimal.

There is a constructor in BigDecimal that takes a BigInteger, so try:

BigDecimal d = new BigDecimal(b);

You can use a decimal/numeric value depending on your db limits.

you can try this way:

 oracle.sql.NUMBER numberValue = new oracle.sql.NUMBER(bigIntegerValue);
 cs.setObject(id, numberValue, OracleTypes.NUMBER);

where bigIntegerValue is an instance of java.math.BigInteger, it works for me

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!