Jump to content
We've recently updated our Privacy Statement, available here ×

james.clayton

Members
  • Posts

    2
  • Joined

  • Last visited

james.clayton's Achievements

Newbie

Newbie (1/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Conversation Starter Rare

Recent Badges

0

Reputation

  1. I must be doing something seriously wrong but I cannot get Jasper Reports to display a simple table displaying the results of a database query. I have a table in the database that I am accessing via HQL "from com.jasper.Order" - the table has two columns orderId & orderDate. All I want to do is to display a table in the report showing the Orders in the database. The jrxml looks like this <?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0 --><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="TSC-D6" pageWidth="1395" pageHeight="842" columnWidth="1300" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="5d0c2737-81b8-4926-a590-1485435fda4a"> <property name="ireport.zoom" value="2.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="Order_DataAdapter.xml"/> <subDataset name="ProductOrder" uuid="0bca6349-f6da-4944-8a18-621d46be4dbd"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="Order_DataAdapter.xml"/> <queryString language="hql"> <![CDATA[from com.jasper.Order]]> </queryString> <field name="orderId" class="java.lang.String"> <fieldDescription><![CDATA[orderId]]></fieldDescription> </field> <field name="orderDate" class="java.util.Date"> <fieldDescription><![CDATA[orderDate]]></fieldDescription> </field> </subDataset> <queryString language="sql"> <![CDATA[select 1 from dual]]> </queryString> <summary> <band height="155"> <componentElement> <reportElement x="10" y="20" width="220" height="80" uuid="2d0a50a3-0cbf-4b6a-b4b5-62feafa59ab6"> <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/> <property name="net.sf.jasperreports.export.headertoolbar.table.name" value=""/> </reportElement> <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd"> <datasetRun subDataset="ProductOrder" uuid="e3927875-e4e2-4de3-bdd9-f280035571e5"/> <jr:column width="140" uuid="6da3aa43-030a-4715-bb5c-c490fdc2d4b2"> <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column1"/> <jr:columnHeader height="30" rowSpan="1"> <staticText> <reportElement x="0" y="0" width="140" height="30" uuid="e2b85196-002e-41d4-9cc2-20782d811027"/> <text><![CDATA[Order Date]]></text> </staticText> </jr:columnHeader> <jr:detailCell height="30"> <textField> <reportElement x="0" y="0" width="140" height="30" uuid="b10f909e-6ca0-4267-9ae5-e5aa88d341a9"/> <textFieldExpression><![CDATA[$F{orderDate}]]></textFieldExpression> </textField> </jr:detailCell> </jr:column> <jr:column width="130" uuid="149ef200-8042-4830-8f99-ff9cfcc60789"> <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column2"/> <jr:columnHeader height="30" rowSpan="1"> <staticText> <reportElement x="0" y="0" width="130" height="30" uuid="7d29bece-47e3-4baa-854e-061c2a2117da"/> <text><![CDATA[Order Id]]></text> </staticText> </jr:columnHeader> <jr:detailCell height="30"> <staticText> <reportElement x="0" y="0" width="130" height="30" uuid="90179672-d45f-497a-980e-c3acea61eee7"/> <text><![CDATA[OrderId]]></text> </staticText> </jr:detailCell> </jr:column> </jr:table> </componentElement> <textField pattern="dd/MM/yyyy"> <reportElement x="70" y="115" width="72" height="15" uuid="95a65977-a12f-467f-a1b0-8d6c13baa123"/> <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> </textField> <staticText> <reportElement x="7" y="115" width="63" height="15" isPrintInFirstWholeBand="true" uuid="495a2de9-f164-449f-a053-c12b88733d16"/> <text><![CDATA[Report Date :]]></text> </staticText> </band> </summary></jasperReport>[/code]The Order_DataAdapter.xml returns a Collection of Java Beans with test data. The data adapter does work as I can use it to display data if the add fields to a details band in a different report & viewed one order page per order. But when I preview the report with the table - it always comes back blank. I have tried running the report in my application using the hibernate connection & again the report comes back empty. If I run the page per order report everything works okay. But I dont want to display each Order in a separate page - I just want a simple table to display all my Orders. I have tried numerous combinations to get the table in the report to work but I am getting nowwhere, it may soon be time to try a different reporting framework....
  2. In Jaspersoft studio if you try to use a Hibernate Session DataAdapter wizard it aks you for a hibernate cfg & properties file. If you fill these in the then test the connection you get an SQLException Caused by: java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@//localhost:1521/XE at java.sql.DriverManager.getConnection(DriverManager.java:689) at java.sql.DriverManager.getConnection(DriverManager.java:208) Which is not suprising as you have not told the adapter where the driver or class files are. The Hibernate Session data adapter wizard doesn't provide a method to add a classpath and the example used in the documentation doesn't make sense, as it is an example of an hibernate data adapter but the image actually shows a wizard where a JDBC data adapter is being created (which does have a classpath option). If you following through the documentation & create JDBC DataAdapter even though you want a Hibernate Session one - add the Driver jars & the jars for your application classes. Test connection works - but so does test connection if you dont fill anything in. If you then create a report & open the report query dialog & select HQL then you can write your HQL - but Jaspersoft is not apply to read the fields from the connection and you have to add the fields by hand then add them to the report. Then if you preview the report you do not get an exception but it just returns "Document is empty" message with no indication what the problem is. Somebody else had similar problem in 2017 & raised a question on StackOverflow here - nobody was able to supply them with a solution. https://stackoverflow.com/questions/46460939/hibernate-session-data-adapter-in-jaspersoft-studio The only way I can get HQL reports to work is if I write the report by hand then invoke the report in Java supplying the hibernate session as parameter. This is of no use for somebody designing the reports as they should be able to preview & test them against their Hibernate datasource.
×
×
  • Create New...