Grails error in debug mode - mysql

I'm using eclipse and Grails 2.5.1 with MySQL DB with driver version 5.1.36 and it is working fine in the Run mode , but when i try to use the debug mode i get the below error :
context.GrailsContextLoaderListener , Error initializing the
application: No suitable driver found for
jdbc:mysql://127.0.0.1/MY_Dev
here is the BuildConfig :
grails.servlet.version = "3.0" // Change depending on target container compliance (2.5 or 3.0)
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.work.dir = "target/work"
grails.project.target.level = 1.6
grails.project.source.level = 1.6
//grails.project.war.file = "target/${appName}-${appVersion}.war"
grails.project.dependency.resolver = "maven" // or ivy
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// specify dependency exclusions here; for example, uncomment this to disable ehcache:
// excludes 'ehcache'
}
log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility
repositories {
inherits true // Whether to inherit repository definitions from plugins
grailsPlugins()
grailsHome()
mavenLocal()
grailsCentral()
mavenCentral()
// uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories
//mavenRepo "http://repository.codehaus.org"
//mavenRepo "http://download.java.net/maven/2/"
//mavenRepo "http://repository.jboss.com/maven2/"
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
// runtime 'mysql:mysql-connector-java:5.1.29'
// runtime 'org.postgresql:postgresql:9.3-1101-jdbc41'
test "org.grails:grails-datastore-test-support:1.0.2-grails-2.4"
runtime 'mysql:mysql-connector-java:5.1.36'
}
plugins {
// plugins for the build system only
build ":tomcat:7.0.55.3" // or ":tomcat:8.0.22"
// plugins for the compile step
compile ":scaffolding:2.1.2"
compile ':cache:1.1.8'
// asset-pipeline 2.0+ requires Java 7, use version 1.9.x with Java 6
compile ":asset-pipeline:2.2.3"
// plugins needed at runtime but not for compilation
runtime ":hibernate4:4.3.10" // or ":hibernate:3.6.10.18"
runtime ":database-migration:1.4.0"
runtime ":jquery:1.11.1"
//security plugin
compile ':spring-security-core:2.0-RC5'
compile ":spring-security-ui:1.0-RC2"
compile ":mail:1.0.7"
compile ":jquery-ui:1.10.4"
compile ":famfamfam:1.0.1"
//internal mails plugin
compile ":grails-direct-messages:1.0"
// Uncomment these to enable additional asset-pipeline capabilities
//compile ":sass-asset-pipeline:1.9.0"
//compile ":less-asset-pipeline:1.10.0"
//compile ":coffee-asset-pipeline:1.8.0"
//compile ":handlebars-asset-pipeline:1.3.0.3"
}
}
and here is the DataSource:
dataSource {
pooled = true
jmxExport = true
driverClassName = "org.h2.Driver"
username = "sa"
password = ""
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
// cache.region.factory_class = 'org.hibernate.cache.SingletonEhCacheRegionFactory' // Hibernate 3
cache.region.factory_class = 'org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory' // Hibernate 4
singleSession = true // configure OSIV singleSession mode
flush.mode = 'manual' // OSIV session flush mode outside of transactional context
}
// environment specific settings
environments {
development {
dataSource {
// dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
// url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
pooled = true
dbCreate = "create-drop"//create-drop
driverClassName = "com.mysql.jdbc.Driver"
username = "***"
password = "***"
url="jdbc:mysql://127.0.0.1/MY_Dev"
}
}
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"
properties {
// See http://grails.org/doc/latest/guide/conf.html#dataSource for documentation
jmxEnabled = true
initialSize = 5
maxActive = 50
minIdle = 5
maxIdle = 25
maxWait = 10000
maxAge = 10 * 60000
timeBetweenEvictionRunsMillis = 5000
minEvictableIdleTimeMillis = 60000
validationQuery = "SELECT 1"
validationQueryTimeout = 3
validationInterval = 15000
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
jdbcInterceptors = "ConnectionState"
defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
}
}
}
}
any recommendations to solve this ?

Related

Why did the quality of the GUI deteriorate by half after creating the exe file with jpackage?

I'm using jpackage to convert the jar file to an exe, with the exe file provided by the internal JRE. As a result of the conversion, good results were obtained, the JRE weighs about 38.5 mb.
When I run the exe, the GUI quality is twice as WORSE as in a normal jar! In addition, the window of the new exe file increases on its own. Thus, very strange changes appear, as if the exe file is trying to imitate a window jar file. I want to point out that I am using libGdx for the GUI.
desktop gradle:
{
plugins { id 'org.beryx.runtime' version '1.8.4' }
sourceCompatibility = 1.8
sourceSets.main.java.srcDirs = ["src/"]
sourceSets.main.resources.srcDirs = ["../android/assets"]
mainClassName = "com.iapp.chess.desktop.DesktopLauncher"
def osName = System.getProperty('os.name').toLowerCase(Locale.ROOT)
project.ext.assetsDir = new File("../android/assets")
task runGame(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
}
task debug(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
debug = true
}
task dist(type: Jar) {
manifest {
attributes 'Main-Class': project.mainClassName
}
dependsOn configurations.runtimeClasspath
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
with jar
destinationDirectory = file("$buildDir/lib")
}
jpackageImage.dependsOn dist
dist.dependsOn classes
eclipse.project.name = appName + "-desktop"
runtime {
options = ['--strip-debug',
'--compress', '2',
'--no-header-files',
'--no-man-pages',
'--strip-native-commands',
'--vm', 'server']
modules = ['java.base',
'java.desktop',
'jdk.unsupported']
distDir = file(buildDir)
jpackage {
jpackageHome = 'C:\\Program Files\\Java\\jdk-17.0.2'
mainJar = dist.archiveFileName.get()
if (osName.contains('windows')) {
imageOptions = ["--icon", file("../icons/icon.ico")]
} else if (osName.contains('linux')) {
imageOptions = ["--icon", file("../icons/icon.png")]
} else if (osName.contains('mac')) {
imageOptions = ["--icon", file("../icons/icon.icns")]
}
}
}
}

JUnit testing null pointer exception

I am new in unit testing and doing some testing in Grails application using JUnit testing.I am using grails-2.3.7. I searched for the error but couldn't get it. When I test my test case, I get following error:
java.lang.NullPointerException: Cannot get property 'mainContext' on null object
at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:195)
at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:244)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:241)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runners.Suite.runChild(Suite.java:127)
at org.junit.runners.Suite.runChild(Suite.java:26)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at org.junit.runner.JUnitCore.run(JUnitCore.java:138)
I am testing a resource.My test code is :
import com.vox.client.portal.DeliveryStatus
import com.vox.client.portal.OrderDetails
import com.vox.client.portal.testing.AbstractResourceTests
import groovy.json.JsonBuilder
import org.junit.Before
import org.junit.Test
class OrderResourceTests extends AbstractResourceTests {
JsonBuilder json;
#Before
void setup() {
super.setUp()
json = new JsonBuilder ()
}
#Test
void "test creating an order"() {
def order = json {
user "vox"
password "vox"
order(
orderDate: "2015.12.25",
orderNumber: "10",
subTotal: "123",
shipping: "21",
discount: "2.2",
netTotalPaid: "5",
creditApplied: "true",
transactionId: "1",
specialInstruction: "abc",
deliveryStatus: "DELIVERED",
memberId: "1",
localOffice: "Bye Bye"
)
}
sendPost('/api/v1/order/create', order)
assertResponseStatus(200)
}
}
Inherited class:
import grails.converters.JSON
import org.grails.jaxrs.itest.IntegrationTestCase
import static org.junit.Assert.assertEquals
import static org.junit.Assert.assertNotNull
import static org.junit.Assert.assertTrue
class AbstractResourceTests extends IntegrationTestCase{
def parsedData
void send(String method, String url, def data) {
def headers = ['Content-Type': 'application/json', 'Accept': 'application/json']
def conStr = (data as JSON)?.toString()
sendRequest url, method, headers, conStr.bytes
}
void sendPost(String url, def data) {
send 'POST', url, data
}
def assertResponseStatus(int httpStatus) {
assertEquals httpStatus, response.status
if (response.text) {
assertTrue(response.getHeader('Content-Type').startsWith('application/json'))
parsedData = JSON.parse response.text
assertNotNull parsedData
} else {
parsedData = null
}
return parsedData
}
}
My BuildConfig.groovy is :
grails.servlet.version = "3.0" // Change depending on target container compliance (2.5 or 3.0)
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.work.dir = "target/work"
grails.project.target.level = 1.6
grails.project.source.level = 1.6
//grails.project.war.file = "target/${appName}-${appVersion}.war"
grails.project.fork = [
// configure settings for compilation JVM, note that if you alter the Groovy version forked compilation is required
// compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
// configure settings for the test-app JVM, uses the daemon by default
test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
// configure settings for the run-app JVM
run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
// configure settings for the run-war JVM
war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
// configure settings for the Console UI JVM
console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256]
]
grails.project.dependency.resolver = "maven" // or ivy
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// specify dependency exclusions here; for example, uncomment this to disable ehcache:
// excludes 'ehcache'
}
log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility
repositories {
inherits true // Whether to inherit repository definitions from plugins
grailsPlugins()
grailsHome()
mavenLocal()
grailsCentral()
mavenCentral()
mavenRepo 'http://maven.restlet.org/'
}
dependencies {
runtime 'mysql:mysql-connector-java:5.1.29'
test "org.gebish:geb-spock:0.12.2"
provided 'org.spockframework:spock-grails-support:0.5-groovy-1.7', {
exclude 'groovy-all'
}
}
plugins {
// plugins for the build system only
build ":tomcat:7.0.52.1"
// plugins for the compile step
compile ":scaffolding:2.0.2"
compile ':cache:1.1.1'
compile ':spring-security-core:2.0-RC5'
// plugins needed at runtime but not for compilation
runtime ":hibernate:3.6.10.9" // or ":hibernate4:4.3.4"
runtime ":database-migration:1.3.8"
runtime ":jquery:1.11.0.2"
runtime ":resources:1.2.7"
compile ':jaxrs:0.10'
compile ":rest-client-builder:2.1.1"
test("org.grails.plugins:geb:0.12.2")
compile ':functional-spock:0.6'
test ":spock:0.7"
}
}

ERROR pool.ConnectionPool - Unable to create initial connections of pool

I am Grails newbie. After doing some basic configuration in Datasource.groovy, my grails app fails to start. I get the below error
Error 2015-07-03 15:27:19,014 [localhost-startStop-1] ERROR pool.ConnectionPool - Unable to create initial connections of pool.
Message: Driver:org.h2.Driver#78f95cf6 returned null for URL:jdbc:mysql://localhost:3306/radb?createDatabaseIfNotExist=true
| Error 2015-07-03 15:27:19,854 [localhost-startStop-1] ERROR context.GrailsContextLoaderListener - Error initializing the application: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is java.lang.NullPointerException
The database radb exists. I have verified it
My Datasource.groovy file for reference as below
dataSource {
pooled = true
jmxExport = true
driverClassName = "org.h2.Driver"
dialect = "org.hibernate.dialect.MySQL5InnoDBDialect"
//username = "sa"
//password = ""
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
// cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' // Hibernate 3
cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' // Hibernate 4
singleSession = true // configure OSIV singleSession mode
flush.mode = 'manual' // OSIV session flush mode outside of transactional context
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:mysql://localhost:3306/radb?createDatabaseIfNotExist=true"
username="root"
password="root"
logSql = true
}
}
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"
properties {
// See http://grails.org/doc/latest/guide/conf.html#dataSource for documentation
jmxEnabled = true
initialSize = 5
maxActive = 50
minIdle = 5
maxIdle = 25
maxWait = 10000
maxAge = 10 * 60000
timeBetweenEvictionRunsMillis = 5000
minEvictableIdleTimeMillis = 60000
validationQuery = "SELECT 1"
validationQueryTimeout = 3
validationInterval = 15000
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
jdbcInterceptors = "ConnectionState"
defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
}
}
}
}
your driverClassName is wrong. use the correct one for mysql (in the environments, e.g. com.mysql.jdbc.Driver), where you need mysql. right now you have:
default: driver=h2, dialect=mysql;
dev: url=mysql
prod: url=h2
you definetly want to clean this up. also make sure, you have the driver in your deps.

not find artifact mysql:mysql-connector-java:

i'm trying to connect grails to mysql but i get this error:
| Loading Grails 2.4.4 | Error There was an error loading the
BuildConfig: Bad artifact coordinates mys
ql:mysql-connector-java-5.1.23-bin, expected format is
<groupId>:<artifactId>[:< extension>[:<classifier>]]:<version(Use
--stacktrace to see the full trace)
| Configuring classpath | Error Resolve error obtaining dependencies:
Could not find artifact mysql:mysq l-connector-java:jar:5.1.23-bin in
grailsCentral (htts://repo.grails.org/grails /plugins) (Use
--stacktrace to see the full trace) | Error Resolve error obtaining dependencies: Could not find artifact mysql:mysq
l-connector-java:jar:5.1.23-bin in grailsCentral
(htts://repo.grails.org/grails /plugins) (Use --stacktrace to see the
full trace) | Error Could not find artifact
mysql:mysql-connector-java:jar:5.1.23-bin in gra ilsCentral
(htts://repo.grails.org/grails/plugins) | Run 'grails
dependency-report' for further information.
how can i fix this error ?
here is my buidconfig:
grails.servlet.version = "3.0" // Change depending on target container compliance (2.5 or 3.0) grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.work.dir = "target/work"
grails.project.target.level =1.6
grails.project.source.level = 1.6
//grails.project.war.file = "target/${appName}-${appVersion}.war"
grails.project.fork = [
// configure settings for compilation JVM, note that if you alter the Groovy version forked compilation is required
// compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
// configure settings for the test-app JVM, uses the daemon by default
test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
// configure settings for the run-app JVM
run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
// configure settings for the run-war JVM
war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
// configure settings for the Console UI JVM
console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256] ]
grails.project.dependency.resolver = "maven" // or ivy
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// specify dependency exclusions here; for example, uncomment this to disable ehcache:
// excludes 'ehcache'
}
log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility
repositories {
inherits true // Whether to inherit repository definitions from plugins
grailsPlugins()
grailsHome()
mavenLocal()
grailsCentral()
mavenCentral()
// uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories
//mavenRepo "htt://repository.codehaus.org"
//mavenRepo "htt://download.java.net/maven/2/"
//mavenRepo "htt://repository.jboss.com/maven2/"
}
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
runtime 'mysql:mysql-connector-java:5.1.23-bin'
// runtime 'org.postgresql:postgresql:9.3-1101-jdbc41'
test "org.grails:grails-datastore-test-support:1.0.2-grails-2.4"
}
plugins {
// plugins for the build system only
build ":tomcat:7.0.55"
// plugins for the compile step
compile ":scaffolding:2.1.2"
compile ':cache:1.1.8'
compile ":asset-pipeline:1.9.9"
// plugins needed at runtime but not for compilation
runtime ":hibernate4:4.3.6.1" // or ":hibernate:3.6.10.18"
runtime ":database-migration:1.4.0"
runtime ":jquery:1.11.1"
// Uncomment these to enable additional asset-pipeline capabilities
//compile ":sass-asset-pipeline:1.9.0"
//compile ":less-asset-pipeline:1.10.0"
//compile ":coffee-asset-pipeline:1.8.0"
//compile ":handlebars-asset-pipeline:1.3.0.3"
}
}
and datasource:
dataSource {
pooled = true
jmxExport = true
driverClassName = "com.mysql.jdbc.Driver"
dialect = "org.hibernate.dialect.MySQL5Dialect"
username = "root"
password = "thanh" } hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false // cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' // Hibernate 3
cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' // Hibernate 4
singleSession = true // configure OSIV singleSession mode
flush.mode = 'manual' // OSIV session flush mode outside of transactional context }
// environment specific settings
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:mysql:/localhost:3306/bkavr"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:mysql:/localhost:3306/bkav"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:mysql:/localhost:3306/bkav"
properties {
jmxEnabled = true
initialSize = 5
maxActive = 50
minIdle = 5
maxIdle = 25
maxWait = 10000
maxAge = 10 * 60000
timeBetweenEvictionRunsMillis = 5000
minEvictableIdleTimeMillis = 60000
validationQuery = "SELECT 1"
validationQueryTimeout = 3
validationInterval = 15000
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
jdbcInterceptors = "ConnectionState"
defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
}
}
}
}
Change runtime 'mysql:mysql-connector-java:5.1.23-bin'
to
runtime 'mysql:mysql-connector-java:5.1.34'
That should pull in the dependency correctly.

how to connect mysql database in grails with intellij IDE

I am new to grails and intellij ide. I have run a grails project in intellij that's ok. But now I need to use mysql database instead of default. I have no idea how to do it. As much as I know i have changed my datasource class like below >>>
dataSource {
pooled = true
driverClassName = "com.mysql.jdbc.Driver"
dialect = "org.hibernate.dialect.MySQL5InnoDBDialect"
properties {
initialSize = 5
maxActive = 10
minIdle = 5
maxIdle = 5
maxWait = 100000
validationQuery = "select 1"
minEvictableIdleTimeMillis = 60000
timeBetweenEvictionRunsMillis = 60000
}
}
hibernate {
cache.use_second_level_cache = false
cache.use_query_cache = false
cache.provider_class = 'net.sf.ehcache.hibernate.EhCacheProvider'
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "update" // one of 'create', 'create-drop','update'
loggingSql = true
url = "jdbc:mysql://localhost/sbicloud_jan_13"
username = "root"
password = "admin"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://192.168.18.12/sbicloud"
username = "zia"
password = "zia123321"
}
}
production {
dataSource {
}
}
}
when I run the app some errors occur in console and the first is as below >>>
Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Can anyone please help me on this?! It will be so helpful for me.
There are more or less 2 approaches:
Modify your BuildConfig.groovy so your application will use MySQL. In the BuildConfig there is a block called 'dependencies'
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
// runtime 'mysql:mysql-connector-java:5.1.20'
}
Uncomment the line:
// runtime 'mysql:mysql-connector-java:5.1.20'
And it will download the dependencies.
Put MySQL JDBC driver inside the grails-app/lib directory...
I posted a blog post sometime ago with instruction for this. Look here