Monday, November 24, 2008

Dev : MSSQL Server Case Sensitivity

Using database such as Oracle will insist that you use the correct case to do a select filter. But, if you use MSSQL 2000/2005, by default it is case-insensitive. You may need to choose it while in installation if I am not mistaken.

Thus, it means that:
select * from user where id = 'admin'
will always produce the same result as
select * from user where id = 'ADMIN'
if it is case_insensitive.

In this case, how would we make sure that our select statement always base on case sensitivity? Esspecially when comparing fields such as password where the case sensitivity is crucial?

Simple, just add 'COLLATE SQL_Latin1_General_CP1_CS_AS' at the end of the select statement to solve the matter.

Thus, by adding these words, it will always make sure that:
select * from user where id = 'admin' COLLATE SQL_Latin1_General_CP1_CS_AS
will always produce different result as
select * from user where id = 'ADMIN' COLLATE SQL_Latin1_General_CP1_CS_AS

If you want to ignore case sensitivity when by default is case-sensitive, then the SQL should be
select * from user where id = 'admin' COLLATE SQL_Latin1_General_CP1_CI_AS

Thursday, November 13, 2008

Dev : Cannot find bean under name org.apache.struts.taglib.html.BEAN

I am getting this error - "Cannot find bean under name org.apache.struts.taglib.html.BEAN" when loading my jsp page. Something is wrong. What could it be?

At first, since it mentioned cannot find something, my thought was to check all my imported libraries. Nope, that wasn't the case. After some finding, finally I just realize that I have forgottten to put in the form name.

As for Struts framework's struts-html.tld to work properly in the page, we should always created the page as such:

<%@ taglib prefix="html" uri="/WEB-INF/struts-html.tld" %>
<html:form action="action_name_mapped_in_struts_config">
... some code...

This is to ensure that the correct naming and mapping is used when we are using struts-html tag.

Friday, August 15, 2008

Dev : MsSQL Drop Only If Exist

If you were to execute "DROP TABLE table1" or "ALTER TABLE table1 DROP COLUMN field1" in MsSQL server, probably you'll encouter error complaining the table or the column does not exist.

So how do you verify such table or column existed before you could drop them? There is a way. By querying the "INFORMATION_SCHEMA" table, you should be able to drop it without the concern of getting error.

Instead of "DROP TABLE table1", we can use
"if exists (SELECT *
WHERE table_name = 'table1')
DROP TABLE table1".

And instead of "ALTER TABLE table1 DROP COLUMN field1", we can use
"if exists (SELECT *
WHERE table_name = 'table1'
and column_name = 'field1')
alter table table1
drop column field1".

Wednesday, August 06, 2008

Dev : div vs span tag

Some of us may come across with the <div>and <span> tag before. What is the difference? Both usage seems almost the same.

Well, not exactly the same, but yes, almost. Both are elements of a document, but <div>is a block element and <span> is an inline element. And what is block and inline? Block elements take the whole section of a page, at least a whole full line, but inline will use as little space as possible, just like filling a gap.

I am <div>a</div>boy.
will produce
I am

I am <span>a</span> boy
will produce
I am a boy.

So, can you see the differences now?

Sunday, July 13, 2008

Fuyoh! Ini Macam Driver Also Got?

Cutting queue, switching lanes without lighting indicator, green means slow, yellow means rush and red means prepare to go.

Fuyoh! Ini macam Driver Also Got?

Well, basically speaking, it seems that many, but hopefully not majority, Malaysian drive in this matter.

Every time when there's a driver cutting into my lane of road without indicator, I'll surely got a sudden shock and pissed off. While everybody is patiently queuing up, all in a sudden an Ah Beng or Ah Lian dig him/herself in front you. But what more I or we can do except whining in the car?

And there you have it in Malaysia, a new concept of traffic lights understanding. When it turns green, 1st, wait until the car in front of you move. 2nd, masuk gear. 3rd, jalan. The next thing you know, the light turns yellow on the fifth car. I've create a short poem to show how Malaysian handle traffic light :

Green go slow-slow,
Yellow is rush and follow,
Red means prepare to go.

Although some of it are road offence, but is there any action taken to these irresponsible drivers? So far, seldom. I never even seen it myself. Should we take this in our own hands? If we did, we shall become the offender rather than the victim.

Wednesday, June 11, 2008

Dev : What is an abstract class

Abstract classes are classes that contain one or more abstract methods. An abstract method is a method that is declared, but contains no implementation. Abstract classes may not be instantiated, and require subclasses to provide implementations for the abstract methods.

Let's look at the following example: Each animal sure has some common actions can be defined in abstract class, but we implement uncommon actions to be implemented in sub class.

public abstract Animal
public void eat(Food food)
// do something with food....
public void sleep(int hours)
// 1000 milliseconds * 60 seconds * 60 minutes * hours
Thread.sleep ( 1000 * 60 * 60 * hours);
catch (InterruptedException ie) { /* ignore */ }
public abstract void makeNoise();

Let's look at a Dog and Cow subclass that extends the Animal class.

public Dog extends Animal
public void makeNoise() { System.out.println ("Bark! Bark!"); }
public Cow extends Animal
public void makeNoise() { System.out.println ("Moo! Moo!"); }

Now you may be wondering why not declare an abstract class as an interface, and have the Dog and Cow implement the interface. Sure you could - but you'd also need to implement the eat and sleep methods. By using abstract classes, you can inherit the implementation of other (non-abstract) methods. You can't do that with interfaces - an interface cannot provide any method implementations.

Sunday, June 01, 2008

Dev : Informix's Logical Log Files 2

I once wrote something on Informix's logical log file issue. After some research online and reading the manual, I can conclude that, for an Informix DBA, most importantly is to frequently monitor the database's logical log file.

As we do an "onstat -l", you might notice something like this:

8cd23475 U------ 1234 1:12345 1000 1000 100.00
8cd23476 U------ 1235 1:23423 1000 1000 100.00
8cd23477 U---C-L 1236 1:65434 1000 750 75.00
8cd23478 U-B---- 1237 1:15543 1000 1000 100.00
8cd23479 U-B---- 1238 1:12553 1000 1000 100.00

Some of the most important thing you might want to see is the "B", "C" and the last number column.

Remember this, the database will stop functioning when the next logical file is not backup. It does not concern whether the next is fill up or not, instead, backed up or not is more important. The last number column will stat the percentage of the logical file being used. So when it reaches 100%, it will move over to the subsequent file.

So, how to determine which logical log file is in use now? Noticed the "C"? It means the current logical log file is being written. For this case, it will continue to write the current, the next, and the next to the next's logical log file. When it reaches back to the 1st logical log file, the database will stop functioning. So, it is better to alway to backup the logical log file, "ontape -a", as often as possible. Maybe once a week?

"B" stands for backup-ed. So meaning that after a backup is being done, you will notice that all the logical log file will have a "B", except for the current logical logfile.

This is what I have understand after reading. I cannot assure that I am 100% correct, but then, hopefully it helps. Happy exploring!

Dev : Java Development Platform Environment

Java is considered as an platform independent development and application, or better known as WORA, which stand for Write Once, Run Anywhere. You can always develope your application on Windows, but run it on Linux, or maybe Solaris, or maybe AIX. As long as you have the correct version of JDK or JRE for that particular platform, any java application will run.

But yet, 1 basic rule for java development, never ever deploy to a platform that you never test your application on. In other words, if your production server is running on Linux, please test your application on Linux environment before moving into the production.

Why did I say so? Because, there are many different mechanism in different platform. For example, if you use your application to execute a Windows command, most probably you won't find that command in Linux. But the worse case is that you might not aware of that when writting the codes. Another fine example is the real path that you might use. You may use "\" in writting real path codes in Windows, but then, unix environment does not recognise this character as a path.

So, remember to test fully on the actual, or more to actual environment before planning moving into production.

Tuesday, May 06, 2008

Dev : Informix's Logical Log Files are Full -- Backup is Needed

Due to certain condition, such as a big chunk of data is trying to roll back, Informix database server tend to use up all the logical spaces that are assigned to it.

If one day you found that your informix server is not functioning properly, why not check at the logical log file first? I've spend my whole day standing in the server room learning this lesson. This is how I manage to resolve it:

1. If logical file is full, You'll see this error in informix's log file : Logical Log Files are Full -- Backup is Needed. You will not be able to search certain tables and you may also encounter table lock often.

2. type onstat -l to list the list of logical file that you have. If it is due to this error, you will see most, if not all, logical space is 100%.

3. type onmode -l to clear logical log file.

4. If the logical space is fully utilised, onmode -l cannot be use. It will not succeed. You need to goto %informix%/etc/onconfig.std (%ONCONFIG file), change the LTAPEDEV value to /dev/null.

5. Run ontape -a to run backup. Follow instruction.

6. Then run onmode -l again to clear logical file one by one.

7. Change back LTAPEDEV to its original value (/dev/tapedev).

8. Restart DB.

*p/s: I've updated the steps as previously I have missed out step number 5.

Wednesday, March 26, 2008

Dev : CVS History

I know everyone of us used to have the problem of finding what file we have updated to CVS recently and our current tortoise CVS doesn't allow to view history by project (I think so), so normally we will manually find the file and check the history 1 by 1. gosh... that's tiring...

I've found a cool software that might help us to do the job and cut down the time we wasted on checking files, and yes, it is free. Please goto
or goto to find a software called "CVSLogger", download and unzip the application into your pc.

Steps To Open A Project (or specific folder, or specific file) History
1. Upon running the application, goto View --> Options.
2. Change the CVS executable path to your tortoise CVS home. Eg: C:\Program Files\TortoiseCVS
3. Click OK to save the changes.
4. Click File --> Open.
5. Locate the Project/Folder/file that you want to view the history.
6. Click OK to load the history.
7. Wait... It might take a long time to load all the history.

And there you are. With this, you can even filter the history by user basis. Enjoy with the new toy. Thanks alot to Sergey Zozulya for the cool application!

Tuesday, March 11, 2008

Dev : Skipping CVS Folder In WinMerge

WinMerge is quite a powerful tool to compare text document and folders, and I am currently using WinMerge 2.4 for quite some time. Comparing folders content couldn't be easier.

But when it comes to comparing development folders with CVS, it could mean just one thing, a hell lot of files. If you have 100 subfolders, then you will see 200 CVS folders, and 200x6=1200 CVS config files. Add on with your original files, you could end up with 2000-3000 files at least.

So what other alternatives do I have to reduce the file compared and viewed? Yes you do. Firstly, use the WinMerge to compare 2 simple folder. After doing that, clickView. Uncheck "Show Identical Files" and "Show Skipped Files". Other than this, I have no idea how to show this menu without comparing anything, it wont even show if just comparing a file.

You wouldn't want to view identical files if you are to use WinMerge in the first place right?

Unchecking the "Show Skipped Files" need you to actually do this second step. Else, it will not take effect on anything. The second step is to create a filter. Click Open and a small window will appear as below.

Click Select beside the filter dropdown, and another window will appear to let you create your own filter. Click New. It will prompt you to choose whether the new filter will be used personally or share. Anyone will do. It doesn't matter. Create a new filter file name called "CVS Filter", and inside the filter file, edit it to look something like this (most importantly is the bolded part) :

## This is a directory/file filter template for WinMerge
name: CVS Filter
desc: CVS Filter

## Select if filter is inclusive or exclusive

## Inclusive (loose) filter lets through all items not matching rules
## Exclusive filter lets through only items that match to rule
## include or exclude
def: include

## Filters for filenames begin with f:

## Filters for directories begin with d:
## (Inline comments begin with " ##" and extend to the end of the line)

\\CVS$ ## CVS

Save it and there you go. Your new CVS filter is ready to be used with the unchecked of "Show Skipped Files".

Now, you will only see those files you really wish to see.

Monday, March 10, 2008

Dev : Java Code Exception, Getting Error Details

In java coding, we used to have try-catch statement mainly for capturing unforeseen code errors such as SQL query error, parsing a non number to number and as such.

Normally within the catch, we will either throw it back to the method that calls it, or print it out using printStackTrace(). If we were to print it to a string or a log file, we will use toString(). But then, printing to a log file using toString() method might not be sufficient for a developer.

[12:34:56] java.lang.NullPointerException

What does this means? I know the application is hitting some variables which had not been assigned to any value, but where is it? I had a thousand lines of code, which is hitting the error? My current catch is as such:

catch (Exception e) {
throw e;

Well, to get a better description on the log file, I would recommend to use these code instead of just e.toString():

catch (Exception e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
throw e;

These code will actually write the more descriptive printStackTrace() to a buffer, and we print the buffer out instead of writing it somewhere else. With these code, I am able to get better description, including which line and what class as such:

[12:34:56] java.lang.NullPointerException
at a.class.package.anotherMethod(
at a.class.package.newMethod(
at a.class.package.main(
Exception in thread "main"

Isn't it better than a single line printout?

Saturday, March 01, 2008

Dev : Replace CVS Files, All Files

Windows file REPLACE command is something very useful that every person should know, esspecially for developers. Let me try elaborate using a scenario.

Using Tortoise CVS in windows to backup as well as managing source code versioning is a life saving attemped. It can help you to know who commited what and most of all, it is free.

But then, what if one day, your source code administrator sends all developers an email :

From today onwards, all CVS source code in SUN server will be moved to MOON server due to disk space issue. Please change your workstation's settings accordingly.



For the time being, I wouldn't know if there is any other ways to make life easier on this matter. All my source code are pointing towards SUN and now you say MOON? Yeah right, easy for you to say... But first of all, how?

By knowing the behaviour of Tortoise CVS, like every developer knows, there will be a hidden folder called "CVS" in each folder that is using CVS for versioning control in your workstation. But what you should really know is that is what's in it. For the time being, lets get straight to the point.

In each hidden CVS folder, there will be a file called Root. The content of Root might appear differently depending on what CVS authentication you use. As example, ":sspi:mydomain\cksgary@sun:/cvs". Notice that the word "sun" behind "@"? This is the keyword. Just replace the sun with moon. But yet, that is not enough. Because there are more than 2 thousand subfolders that contain this Root file. It is not possible for me to change one by one even if I sacrifice my whole day doing this.

And here comes the real life saver. Using windows REPLACE command really helped out. Just follow the steps below :

1. Ok, lets say your working folder is "D:\work". Make a copy of this Root file in "D:\". Please make sure that it is renamed exactly the same as in the working one. Change the content accordingly.
2. Go to "START --> RUN --> type CMD". This will open a command prompt console for you.
3. Type "REPLACE D:\Root D:\work /s". This will then start replacing all files with the name of Root in all folders and subfolders in "D:\work" with the "d:\Root" file.

3 steps, and you're done. This could be used in any other scenarios if there is a need to replace all files with the same name.