Search code examples
grailsdatasourcesql-server-express

Grails Sql Server Express


I would like some help about setting Grails to work with SQL Server Express. I know I have to change the datasource, but I'm not sure exactly what to do, and couldn't find updated information on the web.


Solution

  • You need to change the datasource settings in grails-app/conf/DataSource.groovy

    dataSource {
    
        // Change the values of these properties to the username, password and hostname
        // for your SQL Server database
        username = "sa"
        password = ""
        url = "jdbc:sqlserver://localhost:1433;databaseName=your_database_name_here"
    
        driverClassName = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
        dialect = "org.hibernate.dialect.SQLServerDialect"
    }
    

    You'll need to make sure that the SQL Server JDBC driver is on your classpath either by copying it to the lib directory of the grails application, or configuring it as a runtime dependency in BuildConfig.groovy