java 查看 Jasper 报告执行的 SQL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/209436/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 11:25:50  来源:igfitidea点击:

view SQL executed by Jasper report

javasqljasper-reports

提问by Dónal

When running a Jasper report in which the SQL is embedded in the report file (.jrxml), is it possible to see the SQL that is executed? Ideally, I'd also like to see the values that are substituted for each of the $P{} placeholders.

在运行 Jasper 报告时,SQL 嵌入报告文件 (.jrxml) 中,是否可以看到执行的 SQL?理想情况下,我还希望看到替换每个 $P{} 占位符的值。

Cheers,

干杯,

Don

大学教师

回答by Tahir Akhtar

JasperReports uses the Jakarta Commons Logging API. Commons Logging has a discovery mechanism that connects to logging API you are using in your project.

JasperReports 使用 Jakarta Commons Logging API。Commons Logging 有一个发现机制,可以连接到您在项目中使用的日志 API。

You need to configure logger named "net.sf.jasperreports" in your logging configuration file to control the logging level of JasperReports.

您需要在日志配置文件中配置名为“net.sf.jasperreports”的记录器来控制 JasperReports 的日志记录级别。

If you are using Log4j, you can read this sectionof there documentation for exact details.

如果您使用的是 Log4j,您可以阅读那里文档的这一部分以获取确切的详细信息。

For example you may write something like this in log4j.properties file

例如,您可以在 log4j.properties 文件中编写类似的内容

log4j.logger.net.sf.jasperreports=INFO, Daily

log4j.logger.net.sf.jasperreports=信息,每日

Where "Daily" is name of an appender configured in same properties file.

其中“Daily”是在同一属性文件中配置的 appender 的名称。

回答by Mike Desjardins

Another option is to use p6spy. P6Spy is sort of a "proxy JDBC driver" that sits between the app and the real JDBC driver, and it can log everything that it sees. You should be able to download a copy here: http://www.p6spy.com/

另一种选择是使用 p6spy。P6Spy 是一种位于应用程序和真实 JDBC 驱动程序之间的“代理 JDBC 驱动程序”,它可以记录它看到的所有内容。您应该可以在此处下载副本:http: //www.p6spy.com/

回答by Micha? Piaskowski

If you're using Ms SQL you can use sql profiler, to see every query executed on the server.

如果您使用 Ms SQL,您可以使用 sql profiler,查看服务器上执行的每个查询。

EDIT: Here is an article on enabling sql query logging on MySql server: http://www.howtogeek.com/howto/database/monitor-all-sql-queries-in-mysql/

编辑:这是一篇关于在 MySql 服务器上启用 sql 查询日志记录的文章:http: //www.howtogeek.com/howto/database/monitor-all-sql-queries-in-mysql/

回答by Ichorus

You can adjust your log4j settings to log the running SQL...

您可以调整 log4j 设置以记录正在运行的 SQL...