code: public static byte[] toByteArray(InputStream input) throws SQLException {
          byte[] result = null;
          ByteArrayOutputStream output = new ByteArrayOutputStream();
  
          try {
              copy(input, output);
              result = output.toByteArray();
          } catch (IOException ex) {
              throw new MjdbcSQLException(ex);
          }
  
          TypeHandlerUtils.closeQuietly(output);
  
          return result;
      }
docs: Transfers data from InputStream into byte array
  
  @param input InputStream
  @return array of bytes from InputStream
  @throws SQLException