【发布时间】:2011-01-22 11:35:39
【问题描述】:
我正在使用 groovy gsql 来查询 Mysql 数据库。 localhost(测试模式)上一切顺利,不幸的是,当我切换到远程 db groovy 时,不要查询 db.
代码如下:
def sqlModule = Sql.newInstance("jdbc:mysql://localhost/module-test", "b", "b", "com.mysql.jdbc.Driver")
def sampleQuery(int dataset) {
def SampleQueryList = []
// Sql query
sqlModule.eachRow("""
select b.*
from dataset_group_set_details a, array_data b
where dataset_id = "${dataset}"
and group_set_id = 1
and a.array_data_id = b.array_data_id ;""")
{
def addSample= new Sample(it.toRowResult())
addSample.id = "${it.array_data_id}" as int
addSample.dateCreatedSample = dateFormat.parse("${it.date_created}")
addSample.tissueTypeId = "${it.tissue_type_id}" as int
...
// Add Sample to SampleList
SampleQueryList << addSample
}
return SampleQueryList
在 localhost 模式下,“return SampleQueryList”会返回一个好的列表,但在远程模式下(例如:jdbc:mysql://192.168.209.32/module-test)我的列表是空的。
注意:本地主机和远程数据库中的数据库是相等的。另外,我在远程模式下没有错误。
为什么,在 localhost 模式下 groovy 查询我的数据库而不是在远程模式下?
有什么想法吗?
【问题讨论】: