如何将Spring Boot应用程序连接到DigitalOcean托管DB

时间:2020-09-19 20:02:50

标签: mysql linux spring spring-boot docker

我有Spring Boot应用程序,该应用程序部署在digitalocean的Droplet中。对于mysql,我在Digital ocean上创建Managed Mysql DB。设置digitalocean后,请给我有关连接的信息,例如:

字符串:

mysql://doadmin:show-password@mysqlb1-do-user-8042482-0.b.db.ondigitalocean.com:25060/defaultdb?ssl-mode=REQUIRED

对于连接到本地mysql,我使用以下方法:

jdbc:mysql://localhost:3306/test8?createDatabaseIfNotExist=true&allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=UTC

我无法连接它引发异常:

HHH000342: Could not obtain connection to query metadata : Driver com.mysql.cj.jdbc.Driver claims to not accept jdbcUrl, mysql://doadmin:show-password@mysqlb1-do-user-8042482-0.b.db.ondigitalocean.com:25060/defaultdb?ssl-mode=REQUIRED

我已将Ip添加到“受信任的来源”。 如何正确连接到数据库?

编辑:

我设法与MySqlWorkbench连接,但无法与tomcat和spring boot / intelij上的应用程序连接。

编辑2: 看起来与此建立的连接:

spring.datasource.url = jdbc:mysql://mysqlb1-do-user-8042482-0.b.db.ondigitalocean.com:25060/defaultdb?createDatabaseIfNotExist=true&allowPublicKeyRetrieval=true&requireSSL=true&serverTimezone=UTC
spring.datasource.username= doadmin
spring.datasource.password= password

但是抛出错误:

2020-09-20 14:18:57.531  WARN 10640 --- [           main] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 1146, SQLState: 42S02
2020-09-20 14:18:57.532 ERROR 10640 --- [           main] o.h.engine.jdbc.spi.SqlExceptionHelper   : Table 'defaultdb.hibernate_sequence' doesn't exist

0 个答案:

没有答案