且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Cloud SQL代理和权限不足

更新时间:2022-12-01 11:05:07

Vadim解决了我所问的问题,但是第二个问题-套接字已连接的问题-最终由我的一位同事解决了

Vadim solved the problem that I asked about, but the second problem -- the socket already connected problem -- was eventually figured out by one of my co-workers.

套接字问题的根源与数据源配置有关.事实证明,我正在混合和匹配两种不同的机制来访问Cloud SQL环境.

The root of the socket problem relates to the datasource configuration. It turns out that I'm mixing and matching two different mechanisms for accessing the Cloud SQL environment.

  1. 使用Cloud SQL代理;和
  2. 使用Google套接字工厂

因为我已经成功配置了Cloud SQL代理,所以在Spring Boot环境中不需要怪异的JDBC URL.我可以使用127.0.0.1:5432进行连接,如下所示:

Because I've successfully configured the Cloud SQL Proxy, I don't need that weird JDBC URL in my Spring Boot environment. I can connect using 127.0.0.1:5432, like so:

datasource:
    type: com.zaxxer.hikari.HikariDataSource
    url: jdbc:postgresql://127.0.0.1:5432/[my-database-name]
    username: ${DB_USER}
    password: ${DB_PASSWORD}

现在,我已替换了JDBC URL,我的应用程序已成功连接.

Now that I've replaced my JDBC URL, my app connects successfully.