Get connection metadata Stay organized with collections Save and categorize content based on your preferences.
Retrieve connection metadata from BigQuery. Credential secrets are not returned.
Explore further
For detailed documentation that includes this code sample, see the following:
Code sample
Java
Before trying this sample, follow theJava setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryJava API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.
importcom.google.cloud.bigquery.connection.v1.Connection;importcom.google.cloud.bigquery.connection.v1.ConnectionName;importcom.google.cloud.bigquery.connection.v1.GetConnectionRequest;importcom.google.cloud.bigqueryconnection.v1.ConnectionServiceClient;importjava.io.IOException;// Sample to get connectionpublicclassGetConnection{publicstaticvoidmain(String[]args)throwsIOException{// TODO(developer): Replace these variables before running the sample.StringprojectId="MY_PROJECT_ID";Stringlocation="MY_LOCATION";StringconnectionId="MY_CONNECTION_ID";getConnection(projectId,location,connectionId);}staticvoidgetConnection(StringprojectId,Stringlocation,StringconnectionId)throwsIOException{try(ConnectionServiceClientclient=ConnectionServiceClient.create()){ConnectionNamename=ConnectionName.of(projectId,location,connectionId);GetConnectionRequestrequest=GetConnectionRequest.newBuilder().setName(name.toString()).build();Connectionresponse=client.getConnection(request);System.out.println("Connection info retrieved successfully :"+response.getName());}}}What's next
To search and filter code samples for other Google Cloud products, see theGoogle Cloud sample browser.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.