Im Moment versuche ich, diese documentation zu folgen, um eine Verbindung zu meiner Second Generation Cloud SQL Datenbank herzustellen. Aber meine Anwendung beim Start fehl, da es keine Verbindung herstellen können ..Kann keine Verbindung zur Cloud SQL-Datenbank der zweiten Generation herstellen
Wie die Dokumentation erzählt, habe ich hinzugefügt beide Dienstkonten
[email protected]
[email protected]
als Editor unter IAM.
Ich verwende das IPv4 der Cloud SQL-Instanz, um eine Verbindung herzustellen. Hier wird die Verbindungszeichenfolge:
jdbc:mysql://w.x.y.z:3306/app_db?useSSL=false
aber in der Stackdriver Logging Ansicht sehe ich:
[main] ERROR com.mz.server.BootstrappingServerConfig - Error trying to migrate SQL scripts ..
org.flywaydb.core.api.FlywayException: Unable to obtain Jdbc connection from DataSource
at org.flywaydb.core.internal.util.jdbc.JdbcUtils.openConnection(JdbcUtils.java:56)
at org.flywaydb.core.Flyway.execute(Flyway.java:1385)
at org.flywaydb.core.Flyway.migrate(Flyway.java:1006)
...
Caused by: com.mysql.jdbc.exceptions.jdbc4.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.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
...
Caused by: java.net.ConnectException: Connection timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
...
Beide Fälle sind in derselben Region: us-central1-b
für die Serverinstanzen und us-central1
für die SQL-Instanzen.
Meine app.yaml Datei:
runtime: java
vm: true
runtime_config:
jdk: openjdk8
server: jetty9
env_variables:
'ALPN_ENABLE': 'true' # OPTIONAL
beta_settings:
cloud_sql_instances: mz-test:us-central1:mz-test-cloudsql
health_check:
enable_health_check: false
Ich bin nicht sicher, was hier los ist. Darf ich tatsächlich die lokale IPv4-Adresse der SQL-Instanz verwenden? tatsächlich
Die Dokumentation sagt
„In Ihrem Anwendungscode, zum Beispiel einer Verbindung durch einen Sockel mit folgendem Namen zu öffnen:
/cloudsql/[INSTANCE_CONNECTION_NAME}
“
Aber ich bin nicht sicher, was das würde für die Verbindungszeichenfolge bedeuten.
Ich vermisse auch die Informationen darüber, was Benutzername/Passwort erforderlich ist oder brauche ich hier nicht?
Warum kann ich keine Verbindung herstellen?
In meinem Fall war das Problem Firewall. –