发新话题
打印

技术问题:怎么打印出SQL语句?

技术问题:怎么打印出SQL语句?

我想查看,每次报表使用的SQL的语句!

TOP

最新版本的 jor,默认是输出 sql 的,参照 SqlReader.java的readStart
复制内容到剪贴板
代码:

public RowMeta readStart(Script script, boolean withdata)
        throws jatools.dataset.DatasetException {
        destroy();
        rowCount = 0;
        try {
            if (sql == null) {
                throw new IllegalArgumentException(Util.debug(logger,
                        App.messages.getString("res.620")));
            }
            String sqlcopy = sql;
            if ((sql.indexOf("${") > -1)) {
                if (script instanceof ReportContext) {
                    sqlcopy = (String) ((ReportContext) script).evalTemplate(sql);
                } else {
                    if (context == null) {
                        context = ReportContext.getDefaultContext();
                    }
                    sqlcopy = (String) context.evalTemplate(sql);
                }
            }
            
            Util.debug(logger,sqlcopy);  // 合并后的sql输出到控制台

TOP

发新话题