Hello team,
I have a web service, which is a Java application. I’ve implemented a new functionality that requires a database. This database is not in Render, but in another server.
The connection string is injected into the app via an environment variable DATABASE_CONNECTION and I set a value like jdbc:mysql://lhcp6666.webapps.net/name_of_database
. I set this environment variable via the Environments menu in the web service of Render.com
In local all works well but, when I deploy in Render, I get an error like this
15:53:01.568 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting...
15:53:05.366 [main] ERROR com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Exception during pool initialization.
java.sql.SQLException: Access denied for user 'username_to_connect_to_database'@'ec2-35-157-117-28.eu-central-1.compute.amazonaws.com' (using password: YES)
I don’t know from where that ec2-35-157-117-28.eu-central-1.compute.amazonaws.com
comes from. I do not have any server in AWS and, of course, nothing in my code like that.
The thing is that if I set a value differently, like jdbc:mysql://localhost:3306/db
the error message is different.
15:51:10.431 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting...
15:51:13.432 [main] ERROR com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Exception during pool initialization.
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Which makes total sense, because there is no database in localhost. With this test, I verified that the environment variable was properly set and propagated into my Java application.
Any idea why my Java application tries to connect to a database server that I do not configure?
Thank you!