mysqlspring-boothost

Spring Boot connection to MySQL remote database strato.de


enter image description here

spring:
  datasource:
    url: jdbc:mysql://rdbms.strato.de:3306/dbs1?autoReconnect=true&useSSL=false
    username: dbName
    password: my password
driverClassName: com.mysql.jdbc.Driver

I have to use the Database of strato Host , with the PHP it is possible but in IntelliJ IDEA 2022
my Spring Boot Project I have not any connection with the remote DB

get the Error

HHH000342: Could not obtain connection to query metadata
java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:111) ~[mysql-connector-j-8.0.33.jar:8.0.33]
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:98) ~[mysql-connector-j-8.0.33.jar:8.0.33]
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:90) ~[mysql-connector-j-8.0.33.jar:8.0.33]
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:64) ~[mysql-connector-j-8.0.33.jar:8.0.33]
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:74) ~[mysql-connector-j-8.0.33.jar:8.0.33]
    at com.mysql.cj.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:895) ~[mysql-connector-j-8.0.33.jar:8.0.33]
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:820) ~[mysql-connector-j-8.0.33.jar:8.0.33]
    at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:446) ~[mysql-connector-j-8.0.33.jar:8.0.33]
    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:239) ~[mysql-connector-j-8.0.33.jar:8.0.33]
    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:188) ~[mysql-connector-j-8.0.33.jar:8.0.33]
    at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) ~[HikariCP-5.0.1.jar:na]
    at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359) ~[HikariCP-5.0.1.jar:na]
    at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201) ~[HikariCP-5.0.1.jar:na]
    at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470) ~[HikariCP-5.0.1.jar:na]

enter image description here


Solution

  • Strato does not allow remote access to a database: So nutzen Sie unsere MySQL-Datenbank (How to use our MySQL database)

    Aus Sicherheitsgründen können MySQL-Clients nur innerhalb des Netzwerks (SSH-Server, Webserver) auf die MySQL-Datenbank zugreifen. Ein Zugriff per remote (also vom eigenen PC bzw. von aussen aus), z.B. per ODBC (Open Database Connectivity), ist somit nicht möglich.

    Translation: For security reasons, MySQL clients can only access the MySQL database within the network (SSH server, web server). Remote access (i.e. from your own PC or from outside), e.g. via ODBC (Open Database Connectivity), is therefore not possible.