<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Solution Hacker &#187; sql</title>
	<atom:link href="http://www.solutionhacker.com/tag/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.solutionhacker.com</link>
	<description>This blog provides solutions for enterpreneurs!</description>
	<lastBuildDate>Fri, 10 Sep 2010 04:05:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Reporting solution!</title>
		<link>http://www.solutionhacker.com/implement-your-idea/build-your-website/reporting-solution/</link>
		<comments>http://www.solutionhacker.com/implement-your-idea/build-your-website/reporting-solution/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 08:24:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[2.1. Architect Corner]]></category>
		<category><![CDATA[2.2. Build Your Site]]></category>
		<category><![CDATA[AMF]]></category>
		<category><![CDATA[iBatis]]></category>
		<category><![CDATA[jasper]]></category>
		<category><![CDATA[pagination]]></category>
		<category><![CDATA[pdf generation]]></category>
		<category><![CDATA[pentaho]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[streaming]]></category>

		<guid isPermaLink="false">http://www.solutionhacker.com/?p=205</guid>
		<description><![CDATA[Open source reporting My company needs a reporting engine but it doesn&#8217;t want to go for the expensive commerical ones like MicroStrategy. In fact, I don&#8217;t know why we need to pay so much because there are tools out there for FREE. As usual, I googled the Net and found out two seemingly promising open [...]]]></description>
			<content:encoded><![CDATA[<h2>Open source reporting</h2>
<p>My company needs a reporting engine but it doesn&#8217;t want to go for the expensive commerical ones like <strong>MicroStrategy</strong>. In fact, I don&#8217;t know why we need to pay so much because there are tools out there for FREE. As usual, I googled the Net and found out two seemingly promising open source reporting solution.</p>
<ol>
<li><strong>Pentaho </strong>Reporting</li>
<li><strong>Jasper </strong>Reporting</li>
</ol>
<p>Both of them are bundled with a suite of tools related to <strong>OLAP</strong>, <strong>Data Mining</strong>, <strong>ETL</strong>.. etc. To me, I just want an non-invasive reporting engine that can easily integrate into our architecture. To my dismay, I found out Pentaho doesn&#8217;t go this route. It basically gives you a reporting server configured. You could build your reports and deploy them following the manual. However, I hardly see a reporting solution that could satisfy all the business requirements without customization. All I expected from Pentaho is a jar file with documents that shows me how to use its api to generate reports in different formats and how to integrate with our database. I have attempted to look into the code and extracted the stuff I want from Pentaho. However, I found out the engine is actually not powerful. To strip out the workflow part, it is basically a simple SQL executor that later on will render the result according to the UI info embedded in the report definition. What is wrong with that?</p>
<p><span id="more-205"></span></p>
<ol>
<li>We want to handle <strong>pagination </strong>and <strong>data streaming</strong> as our data volume is huge. In Pentaho, you need to take care these yourself. So, you write your own sql, paginate yourself, stream it yourself if the resultset is huge. Isn&#8217;t it what we are doing without it? Apart from that, each report in Pentaho needs a report definition. It supports dynamic sql via token replacement. It is primitive as I want it to support control flow because I may decide what tables to join based on the input filters.</li>
<li>On the UI side, Pentaho helps you to render your result into graph, table&#8230;etc. Again, I don&#8217;t like this UI solution as well. I found that <strong>JFreeChart </strong>is not as powerful as the Flex solution. I am adopting Flex and it gives me much powerful visualization tool. All I want is to ship my Flex app the data from my query&#8217;s result.</li>
</ol>
<p>How about <strong>Japser</strong>? Pretty much the same but the good thing of Jasper is that it gives you the jar and document of how to use it instead of a reporting server like Pentaho. So, I can use it as report renderer to generate PDF and Excel like other utility libraries I use. So, what is my final solution?</p>
<p>I finally decide to create my own report definition that my Flex UI can take and render out the reporting interface. So, I don&#8217;t need to create form for each report. Apart from that, in my report definition, I have iBatis SQL template embedded. So, I can leverage its dynamic sql feature that supports control flow logic and the auto result class population. Yes, I still need to handle pagination and streaming myself. But, at least, it already saves up my time. The result object populated will return to Flex via AMF. So, I don&#8217;t need to marshal and de-marshal it in xml. It saves the processing time and costs less bandwidth. At the end, my solution combines the best in the market:</p>
<ol>
<li>Powerful reporting widgets provided by Flex</li>
<li>Fast streaming and RPC protocol &#8211; <strong>AMF</strong></li>
<li>Good dynamic sql generation and mapping tool from <strong>iBatis</strong></li>
<li>Good reporting rendering tool from Jasper that helps me to do PDF and Excel generation</li>
</ol>
<p>My solution is more flexible. As I can plugin hibernate map if I don&#8217;t want to write my own sql at all. Apart from that, no UI work is needed to deploy a new report unless my generic reporting interface is not enough.</p>
<p>Later, if I really need the workflow engine provided by Pentaho, I can plug it in. Again, the document provided doesn&#8217;t give us clear instruction or APIs of how to do it.</p>
<h2>Reference</h2>
<p>Below are references I used to build my solution:</p>
<ol>
<li><a href="http://Flexible reporting with JasperReports and iBATIS">Flexible reporting with JasperReport and iBatis</a></li>
<li><a href="http://e-docs.bea.com/kodo/docs41/full/html/ref_guide_dbsetup_lrs.html">How Kodo JPA handles large result set</a> (its <a href="http://edocs.bea.com/kodo/docs41/full/html/ref_guide_optimization.html">optimization</a> guide is good reference even you may not use Kodo)</li>
<li><a href="http://my.advisor.com/articles.nsf/aid/14753">Process Large Result Sets in Java Web Application</a></li>
<li><a href="http://www.ahmadsoft.org/articles/stream/presidents.html">Streaming architecture</a></li>
</ol>
<p>&#160;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.solutionhacker.com/implement-your-idea/build-your-website/reporting-solution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Tips for MySQL</title>
		<link>http://www.solutionhacker.com/data-intelligence/data-store/sql-tips-for-mysql/</link>
		<comments>http://www.solutionhacker.com/data-intelligence/data-store/sql-tips-for-mysql/#comments</comments>
		<pubDate>Thu, 26 Jun 2008 07:08:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[4.1. Store Your Data]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.solutionhacker.com/2008/03/26/sql-tips-for-mysql/</guid>
		<description><![CDATA[Control Flow in SQL SELECT name AS Name, category AS Category, IF(winter&#62;500, &#34;Sells&#34;, &#34;Slow&#34;) AS Trend FROM sales; http://www.roseindia.net/mysql/mysql5/flow-control-constructs.shtml Rename tables RENAME TABLE table1 TO table2; Add a user connect mysql INSERT INTO user VALUES(&#8216;%&#8217;,'monty&#8217;,PASSWORD(&#8216;some_pass&#8217;); FLUSH PRIVILEGES; Monitoring The number of mysql processes running at any given time should be monitored. I do this manually [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Control Flow in SQL</strong></p>
<blockquote>
<p>SELECT name AS Name, category AS Category, <br />
IF(winter&gt;500, &quot;Sells&quot;, &quot;Slow&quot;) <br />
AS Trend FROM sales;  </p>
</blockquote>
<p><a href="http://www.roseindia.net/mysql/mysql5/flow-control-constructs.shtml">http://www.roseindia.net/mysql/mysql5/flow-control-constructs.shtml</a>  </p>
<p><strong>Rename tables</strong></p>
<blockquote>
<p>RENAME TABLE table1 TO table2;  </p>
</blockquote>
<p><strong>Add a user</strong></p>
<blockquote>
<p>connect mysql <br />
INSERT INTO user VALUES(&#8216;%&#8217;,'monty&#8217;,PASSWORD(&#8216;some_pass&#8217;); <br />
FLUSH PRIVILEGES;  </p>
</blockquote>
<p><strong>Monitoring</strong>  </p>
<p>The number of mysql processes running at any given time should be monitored. I do this manually from time to time, using SHOW PROCESSLIST in mysql. I had a problem in the past with processes never expiring and the number of connections maxed out. Set timeout to resolve this.  Put report id and user id in the comment before running the sql. So, you can trace back what the report the sql for and who issued it when you need to kill it or analyze how to fix it.  </p>
<p><strong>Create a table from other table</strong>  </p>
<blockquote>
<p>CREATE TABLE emps2 as select * from emps;  </p>
</blockquote>
<p>One downside to this approach on both MySQL and Oracle is that it doesn&#8217;t make an exact replica of the table, for example any index against the table will not be receated for the new table.  </p>
<blockquote>
<p>CREATE TABLE emp5 like emp;  </p>
</blockquote>
<p>The downside of this method is that the data isn&#8217;t copied across in the way it is using an SQL statement in the create. But it&#8217;s easy to do that using a command like follows.  </p>
<blockquote>
<p>INSERT INTO emps5 select * from emps;  </p>
</blockquote>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.solutionhacker.com/data-intelligence/data-store/sql-tips-for-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
