I'm trying to convert a byte[]
into a java.lang.Object[]
. Basically it's the reverse problem discussed here, and is related to (but different from) my question on callableStatements in Scala.
Bottom line: I have a byte[]
that represents a binary file. I need to pass it to a JDBC callableStatement.setObject()
using createArrayOf("byte", objectArray)
but I can't figure out how to transform my byte[]
into an Object[]
.
This is what I have now... the getBytes()
function returns the byte[]
but this generates a compiler error, of course:
callableStatement.setObject(index, callableStatement.getConnection().createArrayOf("byte", getBytes()));
Unfortunately, this generates a compiler error:
SentimentDao.java:111: error: incompatible types: byte[] cannot be converted to Object[]
Also I'm not entirely sure that the first argument to createArrayOf()
should be byte
(if you know, please add that to your answer too).
Thank you – the help is much appreciated!