Java GCP bigquery simba jdbc 连接超时

问题描述 投票:0回答:2

我尝试使用 simba jdbc 从本地连接 GCP bigQuery 但出现错误。之前我遇到过服务帐户角色权限问题,通过为服务帐户添加必要的角色来解决这些问题

java.sql.SQLException: [Simba][BigQueryJDBCDriver](100004) HttpTransport IO error : Error getting access token for service account: connect timed out, iss: [email protected].
    at com.simba.googlebigquery.googlebigquery.client.BQClient.createAndTestClient(Unknown Source)
    at com.simba.googlebigquery.googlebigquery.client.BQClient.authenticateAndTest(Unknown Source)
    at com.simba.googlebigquery.googlebigquery.core.BQConnection.connect(Unknown Source)
    at com.simba.googlebigquery.jdbc.common.BaseConnectionFactory.doConnect(Unknown Source)
    at com.simba.googlebigquery.jdbc.common.AbstractDataSource.getSimbaConnection(Unknown Source)
    at com.simba.googlebigquery.jdbc.common.AbstractDataSource.getConnection(Unknown Source)
Caused by: com.simba.googlebigquery.support.exceptions.GeneralException: [Simba][BigQueryJDBCDriver](100004) HttpTransport IO error : Error getting access token for service account: connect timed out, iss: [email protected].
    ... 6 more
Caused by: com.simba.googlebigquery.googlebigquery.client.exceptions.JobExecutionErrorException: EXEC_JOB_EXECUTION_ERR
    at com.simba.googlebigquery.googlebigquery.client.requests.jobs.JobsInsertRequest.throwException(Unknown Source)
    at com.simba.googlebigquery.googlebigquery.client.requests.AbstractRequestWithRetry.executeWithRetry(Unknown Source)
    at com.simba.googlebigquery.googlebigquery.client.queryclient.QueryClient.executeDryRun(Unknown Source)
    at com.simba.googlebigquery.googlebigquery.client.BQClient.prepare(Unknown Source)
    at com.simba.googlebigquery.googlebigquery.client.BQClient.createAndTestClient(Unk

import com.simba.googlebigquery.jdbc42.DataSource;

import java.sql.Connection;
import java.sql.SQLException;

public class TEstConnection {
 public static void main(String[] args) {
  System.out.println("Connection check");

  Connection connection = null;
  DataSource ds = new
          com.simba.googlebigquery.jdbc42.DataSource();
  ds.setProjectId("xxx");
  ds.setOAuthPvtKeyFilePath("C:\\Users\\xx\\UI\\GCP\\devgcp.json");
  ds.setOAuthType(0);
  ds.setOAuthServiceAcctEmail("[email protected]");
  ds.setURL("jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443");
  ds.setTimeout(40000000L);
  try {
   connection = ds.getConnection();
  } catch (SQLException e) {
    e.printStackTrace();
  }
 }
}

服务帐户具有所需的角色权限,但我仍然收到错误

jdbc google-bigquery simba
2个回答
0
投票

有两种方法可以验证您的服务帐户。您可能已完成以下两者之一:

OAuth 2.0
Service Account based
身份验证 您可能想再次进行身份验证。

这里是一个 URL,用于使用基于服务帐户的身份验证使用 Progress DataDirect BigQuery JDBC 连接器 连接到 Google BigQuery。

jdbc:datadirect:googlebigquery:AuthenticationMethod=serviceaccount;Project=your-project-id;Dataset=your-dataset;[email protected];ServiceAccountPrivateKey=/path/to/json-key-file

要通过 OAuth 2.0 验证服务帐户,需要访问和刷新令牌。要获取令牌,必须创建OAuth ClientID以获取ClientID和获取授权码所需的Client Secret。这是关于如何通过 OAuth 2.0 进行身份验证的完整且详细的指南


0
投票

@vinayak_narune 我遇到了同样的错误,你能修复它吗?

© www.soinside.com 2019 - 2024. All rights reserved.