1

I have an grails application that uses MySQL for authentication purpose and another application that uses MSSQL for database stuff. I need to combine these together as one application. The datasource for MySQL contains the following

dataSource {
    pooled = true
    driverClassName = "org.h2.Driver"
    username = "sa"
    password = ""
}

The datasource for application using MSSQL contains the following

dataSource {

    pooled = true
    driverClassName = "com.microsoft.sqlserver.jdbc.SQLServerDriver" //jdbc driver downloaded from internet: sqljdbc4.jar and sqljdbc_auth.dll (see DisplayHistorical/grails-app/lib)
    dialect = "org.hibernate.dialect.SQLServer2008Dialect"

    ClassName = "org.hsqldb.jdbcDriver" //Original Code
// enable loggingSql to see sql statements in stdout 
    loggingSql = true

}

How would I combine these? I looked at the tutorial mentioned on this site (How do you access two databases in Grails) but it doesnt talk about adding the drivers

Community
  • 1
  • 1
user2433194
  • 86
  • 2
  • 13

1 Answers1

1

If you follow the link provided earlier, then you would end up with a datasource configuration like below:

environments {
    production {
        dataSource_authentication {
            pooled = true
            url = "jdbc:mysql://yourServer/yourDB"
            driverClassName = "com.mysql.jdbc.Driver"
            username = "yourUser"
            password = "yourPassword"
            ........
        }
        dataSource {
            pooled = true
            driverClassName = "com.microsoft.sqlserver.jdbc.SQLServerDriver" 
            dialect = "org.hibernate.dialect.SQLServer2008Dialect"
            ........
        }
    }
}

Where ever required you can use the authentication datasource explicitly.

dmahapatro
  • 49,365
  • 7
  • 88
  • 117