In Jaspersoft Studio, Sql server procedure returning fewer fields than expected

两盒软妹~` 提交于 2019-12-13 16:31:55

问题


I running a sql server procedure in Jaspersoft Studio (JSS), but the Query Dialog only show one field.

How it looks in JSS:

In the SQL SERVER Management Studio, it works correctly. The procedure returns more than ten fields...

Has anyone seen a similar case? What might be happening?

I wrote a java code to check, and by jdbc java application, show all fields normally:

 Connection conn = VAGASConnectionFactory.getNewConnectionSQLDRIVER(VAGASConnectionFactory.AMBIENTE.DESENV);
    CallableStatement cs = conn.prepareCall("{call pr_cria_tabela_relatorio_parametrizado(90918)}");
    ResultSet rs = cs.executeQuery();
    while(rs.next()) {
        System.out.println(rs.getString(1) + "," + rs.getString(2) + "," + rs.getString(3) + "," + rs.getString(4));
    }

The result of this code runs correctly:

Jéssica Alba,28/04/1981,35,Condado

Jim Carrey,17/01/1962,54,Goiana

But in Jasper Studio, only shows one field.... :-/

The Jasper Studio log when a click to "Read fields":

Start ClassPath Mapping
Mapping: Archive: file:/home/diego.queres/.eclipse/1695504528/configuration/org.eclipse.osgi/bundles/55/1/.cp/lib/jasperreports-6.1.1.jar
Mapping: Archive: file:/home/diego.queres/.eclipse/1695504528/configuration/org.eclipse.osgi/bundles/55/1/.cp/lib/jasperreports-chart-themes-6.1.1.jar
Mapping: Archive: file:/home/diego.queres/.eclipse/1695504528/configuration/org.eclipse.osgi/bundles/55/1/.cp/lib/jasperreports-fonts-6.1.1.jar
Mapping: Archive: file:/home/diego.queres/.eclipse/1695504528/configuration/org.eclipse.osgi/bundles/55/1/.cp/lib/jasperreports-functions-6.1.1.jar
Mapping: Archive: file:/home/diego.queres/.eclipse/1695504528/configuration/org.eclipse.osgi/bundles/40/1/.cp/lib/js-common.jar
Mapping: Archive: file:/home/diego.queres/.eclipse/1695504528/configuration/org.eclipse.osgi/bundles/40/1/.cp/lib/js-extra-classes.jar
End ClassPath Mapping

I'm using Jasper Studio 6.1.1. I tried use Jasper Studio 6.3.0, without success too.


回答1:


After many attempts, what I discovered is the Query Editor is limited to read fields if a have a complex stored procedure (like mine). As my procedure uses cursors and dynamically makes a sql query in a string, reading the procedure scheme is hampered by the Query Editor.

I decided do the following: print the query SQL to the procedure output (print @sql). Then I cut and paste the query that runs (on the procedure output) in the Query Editor window (instead of the procedure call, "exec procedure ...."). Thus the Query Editor can read the fields of the query. After query editor read fields, I delete the query SQL and insert the procedure call again, "exec procedure ....".

Now it worked :-)



来源:https://stackoverflow.com/questions/38877249/in-jaspersoft-studio-sql-server-procedure-returning-fewer-fields-than-expected

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!