Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在grails数据源中同时使用MySQL和MSSQL?_Mysql_Sql Server_Grails - Fatal编程技术网

如何在grails数据源中同时使用MySQL和MSSQL?

如何在grails数据源中同时使用MySQL和MSSQL?,mysql,sql-server,grails,Mysql,Sql Server,Grails,我有一个使用MySQL进行身份验证的grails应用程序和另一个使用MSSQL进行数据库的应用程序。我需要将这些组合在一起作为一个应用程序。MySQL的数据源包含以下内容 dataSource { pooled = true driverClassName = "org.h2.Driver" username = "sa" password = "" } dataSource { pooled = true driverClassName =

我有一个使用MySQL进行身份验证的grails应用程序和另一个使用MSSQL进行数据库的应用程序。我需要将这些组合在一起作为一个应用程序。MySQL的数据源包含以下内容

dataSource {
    pooled = true
    driverClassName = "org.h2.Driver"
    username = "sa"
    password = ""
}
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

}
使用MSSQL的应用程序的数据源包含以下内容

dataSource {
    pooled = true
    driverClassName = "org.h2.Driver"
    username = "sa"
    password = ""
}
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

}
我将如何组合这些?我看了本网站上提到的教程(),但它没有提到添加驱动程序

如果您遵循前面提供的方法,那么您将得到如下数据源配置:

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"
            ........
        }
    }
}
如果需要,您可以明确使用
身份验证
数据源。

如果您遵循前面提供的方法,则最终会得到如下数据源配置:

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"
            ........
        }
    }
}

如果需要,您可以明确使用
身份验证
数据源。

在查看任何其他内容之前,您应该先查看一下。谢谢,在查看其他内容之前,您应该先查看一下。谢谢