Search code examples
grailsjdbcgrails-orm

Grails: Load jdbcDriver in Controller


I have to create a new SQL-Connection in a controller. So I created a new controller and its action where I do

def db = [url:'jdbc:hsqldb:mem:testDB', user:'sa', password:'', driver:'org.hsqldb.jdbcDriver']
def sql = Sql.newInstance(db.url, db.user, db.password, db.driver)

But I do get:

Class: java.lang.ClassNotFoundException
Message: org.hsqldb.jdbcDriver

Importing fails and I can't find information about this in documentation. Can you help? Thank you.


Solution

  • make sure the hsqldb Driver is in the dependencies list in grails-app/conf/BuildConfig.groovy

     dependencies {
    
        //other dependencies
        //...
    
        runtime group: 'org.hsqldb', name: 'hsqldb', version: '2.3.1'
     }