Binary type byte[] storage method of Hive database, Method Not Supported

Hive reports Method Not Supported when storing binary type data through JDBC

Hive's jdbc package does not support direct prepareStatement and direct setObject, setBytes, setByte, and setBlob to store binary data.

Input stream method through setBinaryStream:

First convert the binary array into an input stream:

InputStream input = new ByteArrayInputStream((byte[]) obj);

Then store the binary input stream into the database through setBinaryStream()

Later, when jdbc reads the data, it reads it through the input stream and then converts it into byte[] through the output stream.

InputStream inStream = rs.getBinaryStream(columnName);

ByteArrayOutputStream swapStream = new ByteArrayOutputStream();

byte[] buff = new byte[100]; //Storage temporary data read by loop

Guess you like

Origin blog.csdn.net/icemeco/article/details/119939188