天天看点

ERROR 14158 com.alibaba.druid.pool.DruidDataSource : create connection SQLException, url: jdbc:mys

连接远程数据库报如下错:

报错一: ERROR 14158 --- [reate-947462790] com.alibaba.druid.pool.DruidDataSource   : create connection SQLException, url: jdbc:mysql://39.97.245.16:3306/gulimall_admin?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai, errorCode 0, state 08S01

报错二: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.

报错四:Caused by: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
           

报错时的url:

只需后面添加&useSSL=false即可

其他配置如下:
spring:
    datasource:
        type: com.alibaba.druid.pool.DruidDataSource
        druid:
            driver-class-name: com.mysql.cj.jdbc.Driver
            url: jdbc:mysql://39.97.245.16:3306/admin?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false
            username: eee
            password: eee
            initial-size: 10
            max-active: 100
            min-idle: 10
            max-wait: 60000
            pool-prepared-statements: true
            max-pool-prepared-statement-per-connection-size: 20
            time-between-eviction-runs-millis: 60000
            min-evictable-idle-time-millis: 300000
            #validation-query: SELECT 1 FROM DUAL
            test-while-idle: true
            test-on-borrow: false
            test-on-return: false
            stat-view-servlet:
                enabled: true
                url-pattern: /druid/*
                #login-username: admin
                #login-password: admin
            filter:
                stat:
                    log-slow-sql: true
                    slow-sql-millis: 1000
                    merge-sql: false
                wall:
                    config:
                        multi-statement-allow: true