Thursday, November 27, 2014

Jasper Reports, 1kb PDFs and "I swear they did this on purpose"

I ran into this seemingly weird situation with Jasper Reports 5.0.1 where I was getting 1kb size PDFs which was weird. So after doing *lots* (lots) of debugging I couldn't find anything wrong. The lines where pretty straight forward:

  InputStream is1 = evalSummaryReportPage1.getResource().openStream(); //jrxml source
  Map reportParams1 = new HashMap(); // standard hashmap
  reportParams1.put(......)
  ..
  ..
  JasperDesign page1Design = JRXmlLoader.load(is1);
  JasperReport page1Compiled = JasperCompileManager.compileReport(page1Design);
  JasperPrint page1 = JasperFillManager.fillReport(page1Compiled, reportParams1); 

  JRPdfExporter exporter = new JRPdfExporter();
  exporter.setParameter(JRExporterParameter.JASPER_PRINT, page1);
  exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, filename); 
  exporter.exportReport();

Until I found about JREmptyDataSource class. Apparently the fillReport() method of the JasperFillManager doesn't do shit when it doesn't has a third or the datasource parameter. It was bullshit because the same fillReport methods is overloaded and can be called with only two parameters. You can then compile with no problems or warnings. A warning would have been nice but no. I swear the Jasper devs did this on purpose just to fuck with me.

So to fix this shit:
  ..
  JasperDesign page1Design = JRXmlLoader.load(is1);
  JasperReport page1Compiled = JasperCompileManager.compileReport(page1Design);
  JasperPrint page1 = JasperFillManager.fillReport(page1Compiled, reportParams1, new JREmptyDataSource()); 
  ..
There, it now correctly generates the report.

zzzzzzzzz

Thursday, November 20, 2014

Why u no format SQL SQL Server Management Studio

Microsoft probably just loves developers but not DBAs because I find it amazing that the SQL Server Management Studio (SSMS) doesn't have a format SQL thing. It has the other stuff like Upper or lower case text, indent, undent, comment and uncomment BUT no freakin' format SQL. That is bullshit.

Of course, you could argue that I should buy some of those 1000 dollar plugins like Redgate SQL Prompt but that seems excessive. I just need to format SQL. That's it.

So after googling a bit on this I was able to find PoorSQL which a not only a website that formats SQL but is also a plugin in for SSMS and Visual Studio. Amazingly, it's also a open-source and free.


Friday, November 7, 2014

All up in the clouds

I haven't posted in a long while because I've been busy moving into a new place. Things have settled a bit and I'm starting to write again. This time I'm talking about the two cloud services I've been using: Google App Engine(GAE) and DigitalOcean(DO).

GAE is a platform. Think of folder where you put files and have a specific API to use to interact with your data store. The data store here is Google's. Of course, you could use other ones external from Google like mongolab if you into the whole NoSQL thing. The upside to this is you don't have to worry about maintaining servers, binaries and such. It makes you focus on your app. The downside though is that the "folder" is a sandbox. You are limited to what the API has.

DO is a VM. Think server. You can start off with a bare bones Linux server - there are Debian and Redhat variants - or if you could start off with a complete configured LAMP server. Either way, you will manage this via an SSH connection. The downside, will you have to manage that VM and if you happen to be a sucky (or worst lazy) administrator you might end up screwing up a lot. The upside is you have full control.