I have a report called Analysis which is populated by this simple query:
SELECT * FROM TB_ANL analysis WHERE analysis.CD_ANL = $P{FILTER}
Only one element will be selected (CD_ANL is unique).
When I edit this query in iReports (version 4.7), the Edit Query window actually shows the columns of the table (so it recognizes the table) and I successfully compile the report.
When I try to run it in my server, it accuses a ORA-00942 and says:
net.sf.jasperreports.engine.JRException: Error executing SQL statement for : AnalysisTemplate
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(JRJdbcQueryExecuter.java:229)
at net.sf.jasperreports.engine.fill.JRFillDataset.createQueryDatasource(JRFillDataset.java:758)
at net.sf.jasperreports.engine.fill.JRFillDataset.initDatasource(JRFillDataset.java:623)
at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:1160)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:802)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:746)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:58)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:417)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:247)
at gov.chesf.leilaovenda.nucleo.negocio.analise.RelatorioGerador.gerarRelatorio(RelatorioGerador.java:57)
at gov.chesf.leilaovenda.web.analise.analise.action.Index.gerarAnalise(Index.java:725)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
…
Caused by: java.sql.SQLException: ORA-00942: table or view does not exist
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:745)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:219)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:813)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1049)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:854)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1154)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3370)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3415)
at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(JRJdbcQueryExecuter.java:222)
... 85 more
So, basically, the problem is: I can view the table in iReports and in SQLDeveloper but I can’t fill the report with it because the table or view “Does not exist”. What is wrong with it? Is there any other reason why Jasper wouldn’t be able to see the table?
Things I’ve done before posting here:
-
I Granted the user that Jasper is using.
-
The table exists, yes.
-
I checked the connection in Jasper. It’s the same that Hibernate is using.
Problem solved.
Here was the problem:
It had nothing to do with the iReport itself, but with the schema being used by the user that the connection was logging in as.
The table TB_ANL should be referenced as OWNER.TB_ANL and not just as TB_ANL.
Possible solutions to this:
1) Update the schema to contain TB_ANL
2) Create a Synonym for OWNER.TB_ANL as TB_ANL so everytime you reference the table it will look in OWNER’s schema.