Reputation: 346
I upgraded my plan from the free tier to a dedicated 25 plan. 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. I restarted all the dynos but still no luck. I believe this is a networking issue with Heroku maybe. ANYTHING HELPS
org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Access denied for user 'b3b4204cd59615'@'ip-x-x-x-x.ec2.internal' (using password: YES)] with root cause
java.sql.SQLException: Access denied for user 'b3b4204cd59615'@'ip-x-x-x-x.ec2.internal' (using password: YES)
My MySQL version: 'MySQL Community Server (GPL) version 5.6.50'
And using the most up to date version of 'mysql-connector-java'
implementation 'mysql:mysql-connector-java:8.0.28'
Upvotes: 1
Views: 256
Reputation: 346
OKAY I FIGURED IT OUT! It's not anything obvs so you have to know a back story.
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. Then they show you a way to make a DataSource obj in their documentation with a config file. 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. ie 'db.url', 'db.password', and 'db.username' and it worked.
so when I upgraded, it gave me a new ENV VAR that had the new URL as username and password remained the same. ("CLEARDB_CYAN_CLEARDB_HOSTNAME_1")
so I wasn't using 'CLEARDB_DATABASE_URL' anymore but my own env vars. (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.
so example:
mysql://b3b4204cdxxxxxx:[email protected]/heroku_XXXXXXXXXXXXX?reconnect=true
became:
mysql://b3b4204cdxxxxxx:[email protected]/heroku_XXXXXXXXXXXXX?reconnect=true
Again even though my source code makes no use of this -- IT HAS TO BE UPDATED
Upvotes: 1