java - Convert Long to Raw jdbc -
i have following function defined:
private raw[] longtoraw(long[] toconvert) throws sqlexception { final raw[] toreturn = new raw(toconvert.length); for(int = 0; <toreturn.length;i++) { toreturn[i] = new raw(toconvert[i]); } }
a client passes me long[]
, not change. oracle database talk stores data raw
. data appears correctly persisted. however, upon retrieval unintelligible results.
retrieval code:
... while(results.next()) { string s = new string(results.getbytes(1)); } ...
this not give desired long value passed database. how can resolve issue? issue in way convert long
raw
or in retrieval code?
it appears you're calling deprecated constructor, additionally meant byte
arrays , string
s only. believe appropriate way this:
toreturn[i] = raw.newraw(long.tohexstring(toconvert[i]));
edit: if results
iterator<raw>
, while
-loop should changed this:
while(results.hasnext()) { string s = new string(results.next().getbytes()); }
if results
raw
-array, should this:
for(raw result : results) { string s = new string(result.getbytes()); }
Comments
Post a Comment