** Please check the changes at the bottom of this post
I have a bytebuffer [128 bit] [which has numbers] that I need to convert to bigdecimal, binary, string, since this is the corresponding sql mapping when using jdbc.
Is there a library API that I can use for this. I see that String.valueof () does not accept a byte array as a parameter. Therefore, I adhere to doing something like this:
BigDecimal bd = new BigDecimal(bigmyBuffer.asCharBuffer().toString());
It looks like hacking me. Is there a better way to do this, or rather make the jdbc part efficiently. I am focused on doing insertions in the corresponding sql columns at the moment.
Edit:
I was wrong, the bytebuffers were not just numbers, but all kinds of cue ball. So now I need to take a 128-bit buffer and convert it to 2 longs, and then merge it into bigdecimal so that the numbers keep common sense. So something like this: LongBuffer lbUUID = guid.asLongBuffer ();
firstLong= lbUUID.get();
secondLong = lbUUID.get();
BigDecimal = firstLong + secondLong ;
Thank.
source
share