0

Grails 3.3.1

MAMP PRO 3.5

IntelliJ Idea 2017.2.5

Mac OS X

I can connect to the database using PHP (database works):

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

After a long wait from start build Grails fails with error:

objc[4847]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/bin/java (0x108c4f4c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x108d1d4e0). One of the two will be used. Which one is undefined. 2017-11-02 19:29:05.401 ERROR --- [ main] o.a.tomcat.jdbc.pool.ConnectionPool : Unable to create initial connections of pool.

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) at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

...

2017-11-02 19:34:06.560 ERROR --- [ main] o.a.tomcat.jdbc.pool.ConnectionPool : Unable to create initial connections of pool.

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) at java.lang.reflect.Constructor.newInstance(Constructor.java:423)


Grails settings:

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 !!!
}

This settings works at Windows!

Vitali
  • 93
  • 7
  • *Possbile* duplicate of https://stackoverflow.com/questions/2983248/com-mysql-jdbc-exceptions-jdbc4-communicationsexception-communications-link-fai – Rafa Nov 02 '17 at 18:12
  • Wild guess, but you have a space between the key and the :, eg: `username(space):` - try removing those. YML is a weird format. – erichelgeson Nov 02 '17 at 21:05
  • Are you declaring mysql in the dependencies section of the build.gradle file, and not the buildscript/dependencies? – Mario Nov 02 '17 at 21:05
  • Is the mysql instance also listening in port 8888 in your mac? – Mario Nov 02 '17 at 22:15

0 Answers0