postgresql – 针对内存中的h2数据源运行Jasper报告?
我正在尝试针对实时和报告数据库运行jasper报告,但针对实时数据库运行的任何报告都会抛出有关未找到正确表的异常(尽管找到了默认的PUBLIC模式).看起来主DataSource连接没有遵守指定IGNORECASE = true的H2连接设置,因为生成的列和表是大写的,我的查询不是.
DataSource.groovy dataSource: 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: 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)注入或查找时,live dataSource是TransactionAwareDatasourceProxy,而DatasourcesUtils.getDataSource(‘reporting’)是BasicDataSource 我需要做什么才能使Jasper在活动的内存H2数据库上运行? 对于真正的postgres数据库,此故障无法再现.
可能你正在打开一个不同的数据库.使用数据库URL jdbc:h2:mem:testDb将打开一个
in-memory database within the same process and class loader.
您是否尝试使用常规持久数据库,使用数据库URL jdbc:h2:?/ testDb? 要使用打开在不同进程或类加载器中运行的内存数据库,需要使用server mode.这意味着,您需要运行数据库的start a server,并使用jdbc:h2:tcp连接到它: //本地主机/ MEM:TESTDB. 另见database URL overview. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |