Grails 3:CommunicationsException& ConnectionPool:无法创建池的初始连接

时间:2017-11-02 17:35:21

标签: grails java-ee intellij-idea groovy

Grails 3.3.1

MAMP PRO 3.5

IntelliJ Idea 2017.2.5

Mac OS X

我可以使用PHP(数据库工作)连接到数据库:

$config->dbhost     = "localhost:8888";
$config->dbusername = "root";
$config->dbpass     = "root";
$config->dbname     = 'nsl_api'; 

经过漫长的等待,从开始构建Grails失败并显示错误:

objc [4847]:类JavaLaunchHelper在/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/bin/java(0x108c4f4c0),/Library/Java/JavaVirtualMachines/jdk1.8.0_151中实现.jdk / Contents / Home / jre / lib / libinstrument.dylib(0x108d1d4e0)。将使用两者之一。哪一个未定义。 2017-11-02 19:29:05.401 ERROR --- [main] o.a.tomcat.jdbc.pool.ConnectionPool:无法创建池的初始连接。

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通讯链接失败

成功发送到服务器的最后一个数据包是0毫秒前。驱动程序未收到来自服务器的任何数据包。         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)         在java.lang.reflect.Constructor.newInstance(Constructor.java:423)

...

2017-11-02 19:34:06.560 ERROR --- [main] o.a.tomcat.jdbc.pool.ConnectionPool:无法创建池的初始连接。

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通讯链接失败

成功发送到服务器的最后一个数据包是0毫秒前。驱动程序未收到来自服务器的任何数据包。         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)         在java.lang.reflect.Constructor.newInstance(Constructor.java:423)

Grails设置:

application.yml

...
---
hibernate:
    cache:
        queries: false
        use_second_level_cache: false
        use_query_cache: false
dataSource: # <- CHANGE !!!
    pooled: true
    jmxExport: true
    driverClassName: com.mysql.jdbc.Driver
    dialect: org.hibernate.dialect.MySQL5InnoDBDialect
    username: sa
    password:

environments:
    development:
        dataSource: # <- CHANGE !!!
           username : root
           password : root
           dbCreate : create-drop # one of 'create', 'create-drop', 'update', 'validate', ''
           url : jdbc:mysql://localhost:8888/nsl_api
    test:
        dataSource:
            dbCreate: update
            url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
    production:
        dataSource:
            dbCreate: none
            url: jdbc:h2:./prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
            properties:
                jmxEnabled: true
                initialSize: 5
                maxActive: 50
                minIdle: 5
                maxIdle: 25
                maxWait: 10000
                maxAge: 600000
                timeBetweenEvictionRunsMillis: 5000
                minEvictableIdleTimeMillis: 60000
                validationQuery: SELECT 1
                validationQueryTimeout: 3
                validationInterval: 15000
                testOnBorrow: true
                testWhileIdle: true
                testOnReturn: false
                jdbcInterceptors: ConnectionState
                defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED

的build.gradle

dependencies {
    ...
    runtime 'mysql:mysql-connector-java:5.1.29' # <- CHANGE !!!
}

此设置适用于Windows!

0 个答案:

没有答案