Question

I am setting up a Grails 2.3.5 App on a Heroku Server and I keep getting the following error when tomcat starts up:

    Caused by: java.sql.SQLException: Driver:com.mysql.jdbc.Driver@5a7359fe returned null for URL:jdbc:h2:mem:grailsDB;MVCC=TRUE;LOCK_TIMEOUT=10000 

I am not using h2 as the Database. I would like to use ClearDB. My environment variables all look correct and everything looks correct in DataSource.groovy. I even setup the connection string to be hard coded to see if this would make a difference. Nada.

    production {
        datasource {
            dbCreate = "create-drop"
            url = "jdbc:mysql://us-cdbr-east-05.cleardb.net/heroku_5a952ab6aXXXXXXX?reconnect=true"

            username = "XXXXX"
            password = "xxxxx"
        }
    }

Obviously I'm missing something, but I cannot see what. Where is the production setup getting the h2 connection string from?!

Was it helpful?

Solution 2

I found out the reason for my problems. The code block for data source has a lower case "s" in source. It should have been dataSource, not datasource.

When this block is missing, it appears the default is a h2 database with the name "grailsDB". I could not find this documented anywhere, hence all my confusion.

Check your cases!!!!

OTHER TIPS

You don't show your full DataSource.groovy file, but it probably has the H2 driver in the top section (driverClassName = "org.h2.Driver"). The values there are the defaults, and the environment-specific blocks are merged into that to create the final settings. You can override that in the production block

production {
   datasource {
      dbCreate = "create-drop"
      url = "jdbc:mysql://us-cdbr-east-05.cleardb.net/heroku_5a952ab6aXXXXXXX?reconnect=true"

      username = "XXXXX"
      password = "xxxxx"

      driverClassName = 'com.mysql.jdbc.Driver'
      dialect = org.hibernate.dialect.MySQL5InnoDBDialect
   }
}

Additionally, you should always specify the dialect when using MySQL. Grails auto-detects the dialect well in most cases, but can't determine if you're using MyISAM or InnoDB, so it defaults to a dialect that uses the default engine type configured for the whole server. Newer versions of MySQL default to InnoDB and it's easy to change it in any version, but if you don't or it's an older version you'll end up with non-transactional MyISAM tables. Specifying the dialect ensures that your app uses the proper table type.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top