Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsReferencing .sql file, .jar file
https://www.eclipse.org/forums/index.php/mv/msg/214471/686058/#msg_686058
I've designed a BIRT report which utilizes a scripted data source, which itself references an ArrayList<String[]> returned by a method in a Java class. The class gets its data from querying a database. The query is stored in a .sql file. Everything worked correctly, and the report was populated with data. But then I needed to upload my report to its desination, and I realized I'll have to also upload the SQL file (I could just hardcode it in the class but the query is quite lengthy- over 500 lines- part of the reason I'm using this convoluted method of querying the database). Here I ran into problems. The Java class itself still runs correctly, getting the data. However, the report won't run anymore. I tried including the .sql file in my JAR file, putting it in the workspace directory, etc, but when I try to preview the report I get
Error.ScriptEvaluationError ( 1 time(s) )
detail : org.eclipse.birt.report.engine.api.EngineException: There are errors evaluating script ....
// (my open() script which calls a Java method)
({1}.at
......
....
...
..
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
Caused by: org.eclipse.birt.data.engine.core.DataException: A BIRT exception occurred: Error evaluating Javascript expression. Script engine error: Wrapped java.sql.SQLException: JZ0S4: Cannot execute an empty (zero-length) query. (#3)
Script source: , line: 0, text:
__bm_OPEN(). See next exception for more information.
...
..
//more of the same
None of my scripts have changed- all I've altered is:
1)name of .sql file referenced in Java code.
2)Re-exported JAR file to reflect #1
Any ideas?
Thanks,
Daniel]]>dizzya9342011-06-21T14:27:57-00:00Re: Referencing .sql file, .jar file
https://www.eclipse.org/forums/index.php/mv/msg/214471/686077/#msg_686077
Can you try putting the sql file in the birt resource folder (set in web.xml) then in your javascript (beforeFactory) do this:
mysqlfile = reportContext.getResource("mysql.sql");
This should give you a file location url to the sql file. Pass this to the java class. To check the url put a data item in the report and set its expression
to
mysqlfile;
Jason]]>Jason Weathersby2011-06-21T15:41:31-00:00Re: Referencing .sql file, .jar file
https://www.eclipse.org/forums/index.php/mv/msg/214471/686113/#msg_686113
Thank you,
Daniel]]>dizzya9342011-06-21T18:48:02-00:00Re: Referencing .sql file, .jar file
https://www.eclipse.org/forums/index.php/mv/msg/214471/686635/#msg_686635
While this reportContext.getResource("mysql.sql"); does return an absolute path it will change depending on how it is deployed and should still work. As long as the .sql file is in the resource directory it should not matter how you deploy it.