2014-04-25 53 views
0

我是Java初學者。你能告訴我嗎,爲什麼下面的代碼檢測到錯誤,儘管我相信正是因爲一個例子,谷歌的以下網址給出了相同的代碼: https://developers.google.com/bigquery/streaming-data-into-bigquery#streaminginsertexamples將數據流式傳輸到BigQuery時出現Java代碼錯誤

字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 
     } 
    } 

} 

回答

0

你缺少的BigQuery提供運行該程序所需的必需包和類的jar文件。找到jar並通過命令或在IDE中將其添加到類路徑中。

Maven dependency link for the jar和jar也可以從這個鏈接下載。

0

您需要創建bigquery對象。 (新的NetHttpTransport(),新的JacksonFactory(),新的AppIdentityCredential(SQLSERVICE_ADMIN));以及其他更新。

相關問題