Annyce Davis

Davis Technology Consulting

  • Home
  • About Me
  • Blog
  • Courses
  • Newsletter

Grails: Cannot create JDBC driver of class ‘com.mysql.jdbc.Driver’ for connect URL ‘jdbc:hsqldb:mem:grailsDB’

January 20, 2012 by Annyce Davis

Recently received the following error when attempting to deploy a new war file on my Glassfish server:

Cannot create JDBC driver of class ‘com.mysql.jdbc.Driver’ for connect URL ‘jdbc:hsqldb:mem:grailsDB’

The solution to the issue however, has nothing to do with MySQL and drivers whatsoever.  The problem was that I mistyped the environment name when creating the war file.

I typed grails rstaging war instead of grails staging war.  This is just another example of extremely useful error messages that I’ve encountered while developing for Grails.

Configuration of DataSource.groovy for Highly Concurrent Grails Application

August 7, 2010 by Annyce Davis

In developing a highly concurrent Grails Application, I ran into an issue where many connections were being created to the database and were subsequently not released. After reading several blog posts it seems that the library used to handle the connection pooling was not designed for highly concurrent systems. I found that using the following setup in your DataSource.groovy file eliminates the stale connection issue and allows a high level of concurrency.

dataSource {
pooled = true
driverClassName = “com.mysql.jdbc.Driver”
dialect = “org.hibernate.dialect.MySQL5InnoDBDialect”
properties {
maxActive = 50
maxIdle = 10
initialSize = 10
minEvictableIdleTimeMillis = 10000
timeBetweenEvictionRunsMillis = 20000
maxWait = 10000
validationQuery = “/* ping */”
testWhileIdle = true
numTestsPerEvictionRun = 3
testOnBorrow = true
}
}

Hope this can help someone else.

Improve Performance of Grails Queries in MySQL

January 19, 2010 by Annyce Davis

A web application that I was developing would become extremely slow as the number of requests increased per minute. I couldn’t figure out why because with my local database everything seemed fine. Here is the process that I used in MySQL to determine the bottleneck in my database. The final problem was a missing index on a table that was used in the where clause of a select statement over and over again. I included a snapshot the MySQL Process list at the end of the post. Hope this helps someone.

Steps to Follow:

  • show full processlist;
    • shows each database connection that has been allocated for your database
    • contains the time a connection has been Sleep
    • contains how long a Query is taking to execute, you want this to be less than a second ideally
  • describe <query>;
    • this gives you the database’s plan for executing the query
    • you want the number of rows that will be looked at to be as small as possible
  • show index from <table>;
    • this will list all indices contained on a table
    • this is a quick way to discover if you are missing a key index that could improve query performance
  • create index <tablename_fieldname_idx> on <table>(field);
    • this will add a new index to a table

Configuring MySQL with Grails

June 5, 2009 by Annyce Davis

Here are the steps to configure your Grails application to work with a MySQL database.

  1. Put the MySQL Connector J driver class in the lib folder of your Groovy App.
  2. In the DataSource.groovy file remove the default HSQLDB information and replace with MySQL specific configuration. (Sample file using a database called ‘books’ is shown below)

dataSource {
pooled = true
driverClassName = "com.mysql.jdbc.Driver"
username = "root"
password = "admin"
}

hibernate {
cache.use_second_level_cache=true
cache.use_query_cache=true
cache.provider_class='com.opensymphony.oscache.hibernate.OSCacheProvider'
}

// environment specific settings
environments {
development {
dataSource {
dbCreate = "create-drop"
url = "jdbc:mysql://localhost:3306/books"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://localhost:3306/books"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://localhost:3306/books"
}
}
}

Follow Me

  • Bluesky

Categories

  • Android (61)
  • Career (5)
  • Communication (4)
  • Flutter (1)
  • Git (4)
  • Gradle (4)
  • Grails (23)
  • iOS (1)
  • Java (8)
  • JavaScript (6)
  • Kotlin (17)
  • Life (5)
  • Public Speaking (26)
  • Revenue (2)
  • RxJava (1)
  • Software Development (14)
  • Twitter (3)
  • Uncategorized (11)
  • Video Course (5)

Follow Me

  • Bluesky

Copyright © 2025 · All Rights Reserved · Log in