如何在grails数据源中一起使用MySQL和MSSQL? [英] How to use MySQL and MSSQL together in the grails datasource?
问题描述
我有一个Grails应用程序,它使用MySQL进行身份验证,另一个应用程序使用MSSQL进行数据库工作。我需要将这些组合在一起作为一个应用程序。 MySQL的数据源包含以下内容:
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ .Driver
username =sa
password =
}
使用MSSQL的应用程序的数据源包含以下内容:
dataSource {
pooled = true
driverClassName =com.microsoft.sqlserver.jdbc.SQLServerDriver//从互联网下载的jdbc驱动程序:sqljdbc4.jar和sqljdbc_auth.dll(请参阅DisplayHistorical / grails-app / lib)
dialect =org .hibernate.dialect.SQLServer2008Dialect
ClassName =org.hsqldb.jdbcDriver//原始代码
//启用loggingSql以查看stdout中的sql语句
loggingSql = true
}
如何合并这些?我查看了本网站上提到的教程(如何访问两个数据库在Grails中),但它不会讨论添加驱动程序。
如果您遵循 link ,那么你最终会得到如下的数据源配置:
environments {
生产{
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
........
}
}
}
您可以明确使用认证
数据源。
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
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.
这篇关于如何在grails数据源中一起使用MySQL和MSSQL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!