[英]Java Code error while Streaming Data into BigQuery
我是Java的初學者。 您能告訴我為什么以下代碼檢測到錯誤,盡管我采用了以下Google網址中作為示例給出的完全相同的代碼: https : //developers.google.com/bigquery/streaming-data-into-bigquery# streaminginsert示例
單詞bigquery的底部為紅色,錯誤為:bigquery無法解析。
我記得我想通過使用tabledata()。insertAll()方法一次將數據流式傳輸到BigQuery一條記錄中。
這是我的代碼:
import java.io.IOException;
import java.util.*;
import com.google.api.services.bigquery.*;
import com.google.api.services.bigquery.model.*;
public class sdz1 {
public static void main(String[] args) {
TableRow row = new TableRow();
row.set("Average", 7.7);
TableDataInsertAllRequest.Rows rows = new TableDataInsertAllRequest.Rows();
rows.setInsertId(""+System.currentTimeMillis());
rows.setJson(row);
List rowList = new ArrayList();
rowList.add(rows);
TableDataInsertAllRequest content = new TableDataInsertAllRequest().setRows(rowList);
try
{
TableDataInsertAllResponse response = bigquery
.tabledata()
.insertAll("Vigicolis", "wi_vigicolis", "TestTable", content)
.execute();
// TableDataInsertAllResponse response = new TableDataInsertAllResponse();
// response.bigquery.tabledata().insertAll("Vigicolis", "wi_vigicolis", "TestTable", content).execute();
System.out.println("Response: " + response);
}
catch (IOException e)
{
// handle
}
}
}
您缺少BigQuery的jar文件,該文件提供了運行此程序所需的必需軟件包和類。 找到罐子,然后通過命令或在IDE中將其添加到類路徑中。
罐子和罐子的Maven依賴關系鏈接也可以從此鏈接下載。
您需要創建bigquery對象。
例如:Bigquery bigquery = new Bigquery(new NetHttpTransport(),new JacksonFactory(),New AppIdentityCredential(SQLSERVICE_ADMIN));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.