Reputation: 83
I have installed grails 3.0.2 and xampp server on my system. I want to connect to MySql of Xampp through grails. So made some changes in application.yml file located at grails-app/conf folder now it looks like
dataSource:
pooled: true
jmxExport: true
driverClassName: "com.mysql.jdbc.JDBC4MySQLConnection"//changed driver class
username: root //username
password: 123456 //password
//now in develoment environments i changed dbCreat->update and
//url-> jdbc:mysql://localhost:3306/myDB //i have not made any changes to test and production environments
environments:
development:
dataSource:
dbCreate: update
url: jdbc:mysql://localhost:3306/myDB;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
test:
dataSource:
dbCreate: update
url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
production:
dataSource:
dbCreate: update
url: jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
I am new to grails so i don't know where to place mysql-connector.jar but i have added path of my mysql-connector.jar in .dependencies file located at myProject/build folder.
When i try to run my app it gives a lot of errors and in end it gives exception as
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.JDBC4MySQLConnection at java.net.URLClassLoader$1.run(URLClassLoader.java:372) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:360) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:340) at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(Poole dConnection.java:246) ... 83 more
i am not able to understand error. If their is any step my step tutorial for mysql connection with grails 3.0.2 and jdk 1.8 please post link.
Thanks in advance.
Upvotes: 0
Views: 810
Reputation: 16364
Grails 3.0 uses the Gradle build system for:
build related tasks such as compilation, runnings tests and producing binary distrubutions of your project
So you can add your dependency in the build.gradle
file, inside the dependencies block:
dependencies {
// other dependencies ...
runtime 'mysql:mysql-connector-java:5.1.36'
}
See the Grails Gradle Build documentation and Gradle Dependency Management Basics to learn more about this.
Upvotes: 1