【发布时间】:2011-11-02 21:48:04
【问题描述】:
我正在尝试针对实时和报告数据库运行 jasper 报告,但是针对实时数据库运行的任何报告都会引发关于找不到正确表的异常(尽管找到了默认的 PUBLIC 架构)。看起来主 DataSource 连接不支持指定 IGNORECASE=true 的 H2 连接设置,因为生成的列和表是大写的,而我的查询不是。
DataSource.groovy 数据源:
dataSource {
hibernate {
cache.use_second_level_cache = false
cache.use_query_cache = false
}
dbCreate = "create-drop" // one of 'create', 'create-drop','update'
pooled = true
driverClassName = "org.h2.Driver"
username = "sa"
password = ""
url = "jdbc:h2:mem:testDb;MODE=PostgreSQL;IGNORECASE=TRUE;DATABASE_TO_UPPER=false"
jndiName = null
dialect = null
}
Datasources.groovy 数据源:
datasource(name: 'reporting') {
environments(['development', 'test'])
domainClasses([SomeClass])
readOnly(false)
driverClassName('org.h2.Driver')
url('jdbc:h2:mem:testReportingDb;MODE=PostgreSQL;IGNORECASE=TRUE;DATABASE_TO_UPPER=false')
username('sa')
password('')
dbCreate('create-drop')
logSql(false)
dialect(null)
pooled(true)
hibernate {
cache {
use_second_level_cache(false)
use_query_cache(false)
}
}
}
什么失败了:
JasperPrint print = JasperFillManager.fillReport(compiledReport, params,dataSource.getConnection())
在调试时,我发现的唯一区别是实时数据源在注入或使用DatasourcesUtils.getDataSource(null) 查找时是TransactionAwareDatasourceProxy,而DatasourcesUtils.getDataSource('reporting') 是BasicDataSource
Jasper 需要做什么才能对活动的内存 H2 数据库进行操作?
此故障无法在真实的 postgres 数据库中重现。
【问题讨论】:
标签: postgresql grails jasper-reports grails-orm h2