Skip to content
Snippets Groups Projects
LoadTable.java 1.12 KiB
Newer Older
Mads Greni Arnesen's avatar
Mads Greni Arnesen committed
package com.application.DataBase;

import com.google.cloud.bigquery.*;

// Sample to run query total rows
public class LoadTable {
    public static void main(String[] args) {

        // TODO(developer): Replace these variables before running the sample.
        String projectId = "f-drying-optimization";
        String datasetName = "124";
        String tableName = "int_sd_winccsensordata";
        getTable(projectId, datasetName, tableName);
    }

    public static void getTable(String projectId, String datasetName, String tableName) {
        try {
            // Initialize client that will be used to send requests. This client only needs to be created
            // once, and can be reused for multiple requests.
            BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService();

            TableId tableId = TableId.of(projectId, datasetName, tableName);
            Table table = bigquery.getTable(tableId);
            System.out.println("Table info: " + table.getDescription());
        } catch (BigQueryException e) {
            System.out.println("Table not retrieved. \n" + e.toString());
        }
    }
}