Search code examples
grailsmariadb

How to connect MariaDB with Grails?


I need to link a second database to my system (I have one in grails) and I am not finding the way, what I am using is the following:

dataSource_maria {
 dialect = org.hibernate.dialect.MariaDBDialect
 driverClassName = 'org.mariadb.jdbc.Driver'
 username = 'root'
 password = 'greenArrow2019'
 url = 'jdbc:mariadb://192.168.0.20/db'
 dbCreate = 'validate'
}

Console Error:

| Error 2019-03-18 11:06:40,695 [localhost-startStop-1] ERROR pool.ConnectionPool  - Unable to create initial connections of pool.
Message: org.mariadb.jdbc.Driver
    Line | Method
->>  266 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1149 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    624 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    748 | run       in java.lang.Thread
Caused by ClassNotFoundException: org.mariadb.jdbc.Driver

Thanks!


Solution

  • You need to make sure that you're including the JDBC driver for Maria in your project. For example, in a Grails 3 build.gradle file you could add a dependency on

    compile 'org.mariadb.jdbc:mariadb-java-client:2.4.1'
    

    If you are including the JDBC driver and still getting a class not found exception, please update this question with your build info and grails version so people can help you further.