jayP
jayP

Reputation: 13

Grails 3.0.9 MySql connector

I am haveing problem using MySql with Grails 3 project.

My Application.yml

dataSource:
pooled: true
jmxExport: true
driverClassName: com.mysql.jdbc.Driver
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
username: root
password: *****

environments:
    development:
        dataSource:
            dbCreate: create-drop
            url: jdbc:mysql://localhost:3306/mydb

also tried

environments:
development:
    dataSource:
        dbCreate: create-drop
        url: jdbc:mysql://localhost/mydb

My Build.gradle

dependencies {
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-starter-actuator"
------
runtime 'mysql:mysql-connector-java:5.1.32'

then did a "--refresh-dependencies"

ran the project I get this error:

   ERROR org.apache.tomcat.jdbc.pool.ConnectionPool - Unable to create initial connections of pool.
java.sql.SQLException: com.mysql.jdbc.Driver
    at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:254) ~[tomcat-jdbc-7.0.55.jar:na]
    at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:182) ~[tomcat-jdbc-7.0.55.jar:na]
    at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:701) [tomcat-jdbc-7.0.55.jar:na]
    at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:635) [tomcat-jdbc-7.0.55.jar:na]
    at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:486) [tomcat-jdbc-7.0.55.jar:na]
    at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:144) [tomcat-jdbc-7.0.55.jar:na]
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:116) [tomcat-jdbc-7.0.55.jar:na]

what am I doing wrong?

on the grails2.x there was a lib folder where I can drop a downloaded mysql-connector-java-5.1.32.jar file but on grails 3.x lib folder is missing. please help.:(

Upvotes: 0

Views: 350

Answers (1)

Arjang
Arjang

Reputation: 729

1) Add this to build.gradle

runtime "mysql:mysql-connector-java:5.1.24"

2) then in application.yml file replace H2 database with similar to these lines

dbCreate: update
driverClassName: com.mysql.jdbc.Driver"
dialect: "org.hibernate.dialect.MySQL5InnoDBDialect"
url: jdbc:mysql://localhost/mydbname?useUnicode=yes&characterEncoding=UTF-8"
username: "myusername"
password: "mypassword"

Upvotes: 0

Related Questions