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
Monday, November 24, 2008
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...
</html:form>
This is to ensure that the correct naming and mapping is used when we are using struts-html tag.
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...
</html:form>
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 *
FROM INFORMATION_SCHEMA.TABLES
WHERE table_name = 'table1')
DROP TABLE table1".
And instead of "ALTER TABLE table1 DROP COLUMN field1", we can use
"if exists (SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'table1'
and column_name = 'field1')
alter table table1
drop column field1".
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 *
FROM INFORMATION_SCHEMA.TABLES
WHERE table_name = 'table1')
DROP TABLE table1".
And instead of "ALTER TABLE table1 DROP COLUMN field1", we can use
"if exists (SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
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.
DIV
I am <div>a</div>boy.
will produce
I am
yet,SPAN
I am <span>a</span> boy
will produce
I am a boy.
So, can you see the differences now?
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.
DIV
I am <div>a</div>boy.
will produce
I am
a
boy.yet,SPAN
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.
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)
{
try
{
// 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.
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)
{
try
{
// 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!
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.
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.
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
http://www.download.com/CVS-Logger/3000-2383_4-10411357.html?tag=lst-1
or goto download.com 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!
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
http://www.download.com/CVS-Logger/3000-2383_4-10411357.html?tag=lst-1
or goto download.com 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!
Subscribe to:
Posts (Atom)