Skip to main content

Posts

Showing posts with the label JasperReports

Mysql : The sqls for clone db and rename db

-- -------------------------------------------------------------------------------- -- Clone a db -- Note: comments before and after the routine body will not be stored by the server -- -------------------------------------------------------------------------------- DELIMITER $$ CREATE DEFINER=`dbname`@`%` PROCEDURE `clone_db`(IN old_db VARCHAR(100), IN new_db VARCHAR(100)) BEGIN     DECLARE current_table VARCHAR(100);     DECLARE done INT DEFAULT 0;     DECLARE old_tables CURSOR FOR select table_name from information_schema.tables where table_schema = old_db  and table_type='BASE TABLE';     DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;     OPEN old_tables;     REPEAT         FETCH old_tables INTO current_table;         IF NOT done THEN         SET @output = CONCAT('create table ', new_db, '.', current_table, ' like ', old_db, '.', curren...

64 bits mysql 5 doesn't work on 64 bit windows vista(or 7)

When install the mysql, it came out below Results 1. Prepare configuration (pass) 2. Write configuratin file (pass) 3. Start service (pass) 4. Apply security setting failed with follwoing error Error Nr. 1045 Access denied for user root@localhost (using password:NO) Solution: Here are the steps that worked for me: NOTE: I did not have to open TCP port 3306 at firewall. 1. When service startup fails at MySQL Instance Config Wizard, cancel the wizard, go to Services windows and make sure the MySQL Server is stopped. 2. Execute again MySQL Instance Config Wizard (The service should start now) 3. If step 4 fails (Apply Security Settings), cancel the wizard 4. Create a TXT file (i.e. C:\mysqlpassword.txt) with the following lines UPDATE mysql.user SET Password=PASSWORD('mypassword') WHERE User='root'; FLUSH PRIVILEGES; 5. Open a Command prompt (former DOS console) and execute: (run as administrator ** very important) mysqld --defaults-file="C:...

Time to say good bye

(Hockey) San Jose Sharks won Detroit Red Wings in Game 7 last night. Then   Vancouver  Canucks will face Sharks  this Sunday in Game 1 of the western conference final.  Go Canucks Go. I had very good time to work together with other Tantalusers in the last 6 moths. It is time to say good bye to all of my friends in Tantalus. I got improvement in my English and technologies when I was in Tantalus. Siu-Ki helped me a lot on Oracle PL/Sql. And David showed the way to deal with issues carefully. Each time I talked with Yanik at the new Java Technologies, he can always provide me some surprise and guide me to the correct direction.   Discuss technologies with Ben is always such a good time, I also learned a lot from him. Marc S. is a Scrum master, It's always enjoyable to discuss with him about applying scrum in the team. Thanks to boss Marc, I am more familiar with Jasper Report now and no fearing of any requirement for the jasper report, which is really a gr...

The things I learned from work

Today is the our 7 years wedding anniversary, a very special day for me and my wife. However, I got sick and had to stay at home. In last three days, m y kids got a mild stomach bug, amplified it, multiplied it, enhanced it, and then passed it to me. The project I am working with will be closed in two weeks, and we are going to work with the new version of our product. For me, just finish one project and start another one. I have about 11 years of working experiences, and still, I am struggling for life. In this project, we used JSTL,Jsp,Servlet a lot. And I am crazy of using Jasper Report 1.2, 3.7.6 , 4.0.0 and 4.0.2 for about half a year.  Maybe, I can say I am the expert in using the jasper report and ireport tool.  Boss promised me to work on web service part in the first day I was onboard. It seems this will never come to true. I am regret of missing this valuable opportunity, but, I don't have choice - I am not my boss. I learned a lot about using Ubunto Linu...

How to use the jasper report scriptletClass

1. define the class extends to JRDefaultScriptlet public class ReportScriptlet extends net.sf.jasperreports.engine.JRDefaultScriptlet   // format of strDate: YYYY/MM/DD public static String getFormatedDate(String strDate,String outputFormat){ try {         // Some examples         SimpleDateFormat formatter = new SimpleDateFormat(INPUT_DATE_FORMAT);         Date date = (Date)formatter.parse(strDate.trim());         formatter.applyPattern(outputFormat);         String formatedDate = formatter.format(date);         System.out.println("formatedDate:" + formatedDate); return formatedDate;     }catch (Exception e) {           return strDate; // just don't format the String     } } 2. Added scriptletClass...

Live - solving the jasper report out of memory and high cpu usage problems

I still can not find the solution. So I summary all the things and tell my boss about it. If any one knows the solution, please let me know. Symptom: 1.        The JVM became Out of memory when creating big consumption report 2.        Those JRTemplateElement-instances is still there occupied even if I logged out the system Reason:         1. There is a large number of JRTemplateElement-instances cached in the memory 2.     The clearobjects() method in ReportThread class has not been triggered when logging out Action I tried:      About the Virtualizer: 1.     Replacing the JRSwapFileVirtualizer with JRFileVirtualizer 2.     Not use any FileVirtualizer for c...

jasper reports, formatting field data color based on condition

First drag and drop the field that you want to have dyanamic color twice. Change background color for first field to Yellow and the second field to Red. Now right click Yellow field, click Properties, select Common tab and write this code in the 'Print when expression' box: (make sure to replace myconditionalfield with your actual field name) $F{MyConditinalField}.intValue()>= 5 && $F{MyConditinalField}.intValue()<10?Boolean.TRUE:Boolean.FALSE //if >=5 and <10 then show Yellow field //Code for Red field at the same place just like above $F{MyConditinalField}.intValue()>= 10?Boolean.TRUE:Boolean.FALSE Hope this helps.

Stretch a row if data overflows in jasper reports

It is very common that some columns of the report need to stretch to show all the content in that column. But  if you just specify the property " stretch with overflow' to that column(we called text field in jasper report world) , it will just stretch that column and won't change other columns, so the row could be ridiculous. Haven't find the solution from internet yet. So I just review the properties in iReport one by one and find two useful properties(the bold  highlighted in example below) which resolve the problems.   example: <band height="20" splitType="Stretch" > <textField isStretchWithOverflow="true" pa...

JasperReports - Configuration Reference

Data Source / Query Executer net.sf.jasperreports.csv.column.names.{arbitrary_name} net.sf.jasperreports.csv.date.pattern net.sf.jasperreports.csv.encoding net.sf.jasperreports.csv.field.delimiter net.sf.jasperreports.csv.locale.code net.sf.jasperreports.csv.number.pattern net.sf.jasperreports.csv.record.delimiter net.sf.jasperreports.csv.source net.sf.jasperreports.csv.timezone.id net.sf.jasperreports.ejbql.query.hint.{hint} net.sf.jasperreports.ejbql.query.page.size net.sf.jasperreports.hql.clear.cache net.sf.jasperreports.hql.field.mapping.descriptions net.sf.jasperreports.hql.query.list.page.size net.sf.jasperreports.hql.query.run.type net.sf.jasperreports.jdbc.concurrency net.sf.jasperreports.jdbc.fetch.size net.sf.jasperreports.jdbc.holdability net.sf.jasperreports.jdbc.max.field.size net.sf.jasperreports.jdbc.result.set.type net.sf.jasperreports.query.chunk.token.separators net.sf.jasperreports.query.executer.factory.{language} net.sf.jasperreports.xpath....