简体   繁体   English

无法从 Data Fusion 连接 Cloud SQL mySql/postgreSQL 实例

[英]Unable to connect Cloud SQL mySql / postgreSQL instance from Data Fusion

Goal is to connect Cloud SQL mysql or postgreSQL instances using Cloud Data Fusion.目标是使用 Cloud Data Fusion 连接 Cloud SQL mysql 或 postgreSQL 实例。

  • created Cloud SQL instances with MySQL and postgreSQL使用 MySQL 和 postgreSQL 创建 Cloud SQL 实例
  • created Cloud Data Fusion instance创建 Cloud Data Fusion 实例
  • From wrangler > Add connection > Cloud SQL MySQL从 wrangler > 添加连接 > Cloud SQL MySQL
  • Added Data Fusion instance as member in IAM and added permissions to following Cloud SQL Client Cloud Data Fusion API Service Agent将 Data Fusion 实例添加为 IAM 中的成员,并添加了以下 Cloud SQL 客户端 Cloud Data Fusion API 服务代理的权限
  • In add connection used jdbc url as jdbc:mysql://google/mysql?cloudSqlInstance=&socketFactory=com.google.cloud.sql.mysql.SocketFactory&useSSL=false在添加连接中使用 jdbc url 作为 jdbc:mysql://google/mysql?cloudSqlInstance=&socketFactory=com.google.cloud.sql.mysql.SocketFactory&useSSL=false
  • Added driver for mySQL: mysql-connector-java-5.1.39-bin.jar为 mySQL 添加了驱动程序:mysql-connector-java-5.1.39-bin.jar
  • Added MySQL socket factory jar as library.添加 MySQL 套接字工厂 jar 作为库。

While testing connection, it fails with error: com.mysql.jdbc.Driver在测试连接时,它失败并显示错误:com.mysql.jdbc.Driver

Expecting testing of the connection with Cloud SQL MySQL to be successful so that the data fusion pipeline can be built.期待与 Cloud SQL MySQL 的连接测试成功,以便构建数据融合管道。

The issue is that you need to provide a jar that has both the driver and the connector included.问题是您需要提供一个包含驱动程序和连接器的 jar。 You can find instructions on how to build a uberjar (also called a farjar) using the driver and JDBC Socket Factory from this post here .您可以在此处的这篇文章中找到有关如何使用驱动程序和 JDBC Socket Factory 构建 uberjar(也称为 farjar)的说明。

Edit: Here is a POM for MySQL:编辑:这是 MySQL 的 POM:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.example</groupId>
   <artifactId>mysql-with-cloud-sql-socket-factory</artifactId>
   <packaging>pom</packaging>
   <version>0.0.1</version>

   <dependencies>
      <dependency>
         <groupId>mysql</groupId>
         <artifactId>mysql-connector-java</artifactId>
         <version>8.0.17</version>
      </dependency>
      <dependency>
         <groupId>com.google.cloud.sql</groupId>
         <artifactId>mysql-socket-factory-connector-j-8</artifactId>
         <version>1.0.14</version>
      </dependency>
   </dependencies>

   <build>
      <plugins>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.4.1</version>
            <configuration>
               <!-- get all project dependencies -->
               <descriptorRefs>
                  <descriptorRef>jar-with-dependencies</descriptorRef>
               </descriptorRefs>
            </configuration>
            <executions>
               <execution>
                  <id>make-assembly</id>
                  <!-- bind to the packaging phase -->
                  <phase>package</phase>
                  <goals>
                     <goal>single</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>
      </plugins>
   </build>
</project>

It is a bit annoying to see "error: com.mysql.jdbc.Driver not found" and nothing more that can point to the root cause.看到“error: com.mysql.jdbc.Driver not found”有点烦人,没有更多可以指出根本原因的内容。 Nevertheless, the error message in Data Fusion it is correct because the mysql Driver class is not included when the package is manually built .尽管如此,Data Fusion 中的错误消息是正确的,因为手动构建包时不包含 mysql Driver 类。 The issue is coming from this line:问题来自这一行:

<scope>provided</scope>

in the cloud-sql-jdbc-socket-factory/connector-j-8/pom.xml file which means that the target package won't include the mysql-connector-java jar file, the one that contains com.mysql.jdbc.Driver and others.cloud-sql-jdbc-socket-factory/connector-j-8/pom.xml文件中,这意味着目标包将不包含mysql-connector-java jar 文件,该文件包含com.mysql.jdbc.Driver等。 The error can be resolved if you construct the jar connector without the aforementioned line.如果您在没有上述行的情况下构建 jar 连接器,则可以解决该错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法从 Data Fusion 连接 Cloud SQL PostgreSQL - Could not connect Cloud SQL PostgreSQL from Data Fusion 无法连接 GCP 云 SQL 私有实例 - Unable to connect to GCP cloud SQL private instance 使用 Cloud Data Fusion 从 MySql 在 Bigquery 中追加增量数据 - Appending incremental data in Bigquery from MySql using Cloud Data Fusion 如何在 Cloud Data Fusion 上的 PostgreSQL 中执行 upsert 操作 - How to perform upsert operation in PostgreSQL on Cloud Data Fusion 如何在 Cloud Data Fusion 中将牧马人连接添加到云 sql postgres - How to add wrangler connection to cloud sql postgres in Cloud Data Fusion 如何从其他服务器连接到Google Cloud SQL实例 - How to Connect to a Google Cloud SQL Instance from a Different Server 无法从Google App Engine节点连接到Cloud sql中的Postgres - Unable to connect to postgres in cloud sql from google app engine nodes 无法从同一本地网络ping和连接云堆栈VM实例IP - Unable to ping and connect cloud stack vm instance ip from the same local network 无法在Windows 7 PC上使用pgAdmin连接到HP Cloud中的PPAS实例 - unable to connect to PPAS instance in HP Cloud using pgAdmin on Windows 7 PC 从本地 Python IDE 连接云 Sql - cloud Sql connect from Local Python IDE
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM