简体   繁体   English

在 ClearDB 上升级计划,部署到 heroku 时无法连接

[英]Upgraded plans on ClearDB and unable to connect when deployed to heroku

I upgraded my plan from the free tier to a dedicated 25 plan.我将我的计划从免费套餐升级到专用的 25 套餐。 When I updated and tested locally I am ABLE to connect.当我在本地更新和测试时,我能够连接。 Same with workbench, I could query my data.与工作台一样,我可以查询我的数据。

When I updated my Env vars in Heroku tho, it fails to establish a connection without any real error.当我在 Heroku 中更新我的 Env vars 时,它无法建立连接而没有任何真正的错误。 I restarted all the dynos but still no luck.我重新启动了所有的测功机,但仍然没有运气。 I believe this is a.networking issue with Heroku maybe.我相信这可能是 Heroku 的网络问题。 ANYTHING HELPS任何帮助

org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; org.springframework.jdbc.CannotGetJdbcConnectionException: 无法获取 JDBC 连接; nested exception is java.sql.SQLException: Access denied for user 'b3b4204cd59615'@'ip-xxxx.ec2.internal' (using password: YES)] with root cause嵌套异常是 java.sql.SQLException:访问被拒绝用户 'b3b4204cd59615'@'ip-xxxx.ec2.internal'(使用密码:是)] 与根本原因

java.sql.SQLException: Access denied for user 'b3b4204cd59615'@'ip-xxxx.ec2.internal' (using password: YES) java.sql.SQLException:拒绝用户'b3b4204cd59615'@'ip-xxxx.ec2.internal'的访问(使用密码:是)


My MySQL version: 'MySQL Community Server (GPL) version 5.6.50'我的 MySQL 版本:'MySQL 社区服务器 (GPL) 版本 5.6.50'

And using the most up to date version of 'mysql-connector-java'并使用最新版本的“mysql-connector-java”

implementation 'mysql:mysql-connector-java:8.0.28'

OKAY I FIGURED IT OUT.好吧,我想通了。 It's not anything obvs so you have to know a back story.这不是什么obvs所以你必须知道一个背景故事。

When you add clearDB to the project it automatically creates a ENV var of 'CLEARDB_DATABASE_URL' and that is a string that has username, password, and url data stored in it.当您将 clearDB 添加到项目中时,它会自动创建一个名为“CLEARDB_DATABASE_URL”的 ENV var,这是一个字符串,其中存储了用户名、密码和 url 数据。 Then they show you a way to make a DataSource obj in their documentation with a config file.然后他们向您展示了一种在其文档中使用配置文件创建 DataSource obj 的方法。 Expecting you to follow that exactly I guess.我猜希望你完全遵循这一点。

Well I didn't want to make a config but rather have spring do the work for me with setting them in application.properties and then injecting that with env vars dedicated to each value.好吧,我不想进行配置,而是让 spring 为我完成工作,在 application.properties 中设置它们,然后使用专用于每个值的环境变量注入它。 ie 'db.url', 'db.password', and 'db.username' and it worked.即“db.url”、“db.password”和“db.username”,它有效。

so when I upgraded, it gave me a new ENV VAR that had the new URL as username and password remained the same.因此,当我升级时,它给了我一个新的 ENV VAR,其中包含新的 URL,因为用户名和密码保持不变。 ("CLEARDB_CYAN_CLEARDB_HOSTNAME_1") (“CLEARDB_CYAN_CLEARDB_HOSTNAME_1”)

so I wasn't using 'CLEARDB_DATABASE_URL' anymore but my own env vars.所以我不再使用“CLEARDB_DATABASE_URL”,而是使用我自己的环境变量。 (like this) (像这样)

spring:
  datasource:
    driverClassName: com.mysql.cj.jdbc.Driver
    username: ${db.username}
    password: ${db.password}
    url: ${db.url}

Well, I'm pretty sure they are some behind the scenes.networking permissions going on that looks at that value and allows access to it or something, as what I did to fix my issue is although I'm not using that var anymore, I took the new URL value and replaced the old with it to point at my new Datasource connection in the ENV var of 'CLEARDB_DATABASE_URL' and once I restarted my dynos again, It was able to connect successfully deployed.好吧,我很确定他们是幕后的一些人。正在进行的网络权限会查看该值并允许访问它或其他东西,因为我为解决我的问题所做的是虽然我不再使用那个 var,我采用了新的 URL 值并用它替换旧值以指向“CLEARDB_DATABASE_URL”的 ENV var 中的新数据源连接,一旦我再次重新启动我的测功机,它就能够成功部署连接。

so example:所以例子:

mysql://b3b4204cdxxxxxx:password@us-xxxx-xxxx-03.cleardb.com/heroku_XXXXXXXXXXXXX?reconnect=true

became:变成了:

mysql://b3b4204cdxxxxxx:password@us-mm-xxx-xxxxxxxxxx.g5.cleardb.net/heroku_XXXXXXXXXXXXX?reconnect=true

Again even though my source code makes no use of this -- IT HAS TO BE UPDATED同样,即使我的源代码没有使用它——它必须被更新

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM