What is the root error "Could not establish a connection to the database. Check the connection string, username and password."

Looking through google and stackoverflow, I found several questions asking about "Could not connect to the database. Check the connection string, username and password." However, I cannot find anyone to find what is the main mistake.

I am trying to write my first Google script with a database connection; I have mysql and oracle jdbc getConnection, both of which raise this error. I checked, double- and thrice checked connection information to no avail. I know that databases are available (they can be entered through other clients from several different computers, such as php on a Linux box, an SQL developer on different Windows computers at home and at work). How do I determine what is the real mistake? The error presented to me is too general and abstract.

Environment: using the script in a Google spreadsheet (thus inheriting from any environment installed by Google). I am trying to use the Google jdbc API and no longer know about environment variables.

Using the following syntax:

var url = "jdbc:mysql://mysql.cb-pta.com:3306/u4lottery";
var conn = Jdbc.getConnection(url, user, password); 

Again, the user and password have been verified.

+3
3

, jdbc . IP-.

, .. 2 ....

....

0

, . Script Google CloudSQL :

Jdbc.getCloudSqlConnection('jdbc:google:rdbms://<IP>/<DB_NAME>', '<USER>', 'PASSWORD');

JDBC MySQL ( ):

Jdbc.getConnection('jdbc:mysql:// ...same as above...

, '/' DB_NAME - user/passwd!

, , - - IP- ( Script, , , Google, IP- ). , (0.0.0.0/0)

+4

This may be because your database is behind a firewall. According to Google documentation (in this case, Google Data Studio, but generally applicable): “If your database is behind a firewall, you need to open access to all of the following IP addresses. They are used by Data Studio to connect and query your MySql database. "

IP addresses here among other places: https://support.google.com/datastudio/answer/7088031

0
source

All Articles