Thursday, October 28, 2010

Block characters in excel sheet using jxl api java

Hi,

Today one of my project which was getting used in Serbia started giving a problem, users started complaining that they are getting square block characters between text. Now, this problem was due to different character-set which was handled upto a certain extent when i initially developed this project. I tried all sorts of things to handle this issue and finally i came up with a solution below :

 if(myText!=null)
 {
 label = new Label(0, a, "Header", cellFormat1);
 sheet5.addCell(label);


a=a+1;  

                                                
if(myText.substring(myText.length()-1, myText.length()).equals("\n"))
{
                                                   
 label = new Label(0, 1, myText.replace('\r',' ').replaceAll("[^\\p{ASCII}]",""), myCellFormat);
 sheet5.addCell(label);


}//end of sub-if
//end of main-if








//end of code


************here's the explanation for the code*********

1) [^\\p{ASCII}]

This says "replace all occurences of one or more non-ASCII characters with nothing." So the new string will be the old string minus all non-ASCII characters. You just check the new String's length.

Or you could just iterate over the string, checking if each char is between 0x00 and 0x7F.





2) '\r'
This was for removing carriage returns which were getting displayed in my excel sheet as block characters   

Finally, at the end of my day, this issue got resolved and for multiple countries this issue got resolved.

Regards,

Ujjwal Soni                                                                                              

Tuesday, October 26, 2010

View SQL generated in IBATIS

To View the SQL Being executed in Ibatis.
Use com.ibatis.sqlmap.engine.mapping.SimpleDynamicSql.java's getSql() method in Ibatis.jar. This method gives you the sql being executed by the ibatis data mapper after all the dynamic elements have been replaced.

Sphere: Related Content

You can also breakpoint in your favourite IDE of your choice. I usually did this for the SimpleDynamicSql class of Ibatis.

Monday, October 25, 2010

Ibatis Vs Hibernate

I have using Hibernate and Ibatis for a year now, and I find myself switching twice from Hibernate to iBatis, not because one is better than the other, it's because of what preperations each framework needs.

In hibernate you need to have a proper plan to design your database, the database is controled by the hibernate roles and you spend time try to fullfill these rules, and if you go the other way (database->OO) it's harder.

With Ibatis I find myself getting the Job done faster, I create any POJO any set of tables, and I link them, much flixability in that field, but little extra work, building Queries and managing Maps (but hay, you spend time with hibernate maps too).

Both are good in a way with iBatis you finish the Job faster, which I like, but you won't have the big tools that hibernate provide, nor iBatis will provide the facility to generate the sql for you.

With Hibernate3 it maybe a different story, since allot of what can stop you in H2 and make you think of iBatis is there in H3, still iBatis is growing up.

ibatis:
-Simpler
-faster development time
-flixable
-Much smaller in package size

hibernate:
-generate SQL for you which means you don't spend time on SQL
-provide much more advance cache
-scalable

For now I use iBatis, but keeping my eyes on Hibernate3, by the way, you can always use iBatis to have a fast start, and move to hibernate on late stages if you want, iBatis provide special DAO framework for that.

Learn both, use both, and if you don't have time learn and use iBatis, you won't regret it.

Friday, October 22, 2010

Wednesday, October 20, 2010

Excellent Applet

Hi,

Check this out for some excellent applet creations..

 http://lar5.com/cube/examples.html

Cheers,

Ujjwal Soni

working set in myeclipse / eclipse

You can assign one or several projects to a working set. The advantage of the working set: If you work on many projects, you do not display all project in the package explorer.

Working sets are a concept derived to help the developer categorize resources across projects into a contextually relevant representation. At its core, working sets are simply, as their name suggests, a sub-set of files/classes/folders/projects that represent a certain developer workflow.

Developers have a lot of options when dealing with working sets. 































Choose the button New...

Choose the working set type.










Set a name for the working set and assign the projects.











The package explorer shows the selected working set with the assigned projects.






















On the drop down menu you can see which working set is activated. You can deselect the working set with the option Deselect Working Set. 

Installing Ubuntu inside Windows using VirtualBox

Hi,

Here's a nice article on intalling ubuntu linux under windows as virtual machine and it really works great...

Check below link :::

http://www.psychocats.net/ubuntu/virtualbox

Monday, October 18, 2010

Java satellite tracker

Hi,

JSatTrak is a Satellite tracking program written in Java. It allows you to predict the position of any satellite in real time or in the past or future. It uses advanced SGP4/SDP4 algorithms developed by NASA/NORAD or customizable high precision solvers to propagate satellite orbits. The program also allows for easy updating of current satellite tracking data via CelesTrak.com. Because this application was written in Java, it should run on almost any operating system or directly off the web using java web start!

http://www.gano.name/shawn/JSatTrak/

Cheers!!!

Ujjwal Soni

Satellite Communications Systems: Systems, Techniques and Technology