HSQLDB Tip: Case Insensitive LIKE Query in HSQLDB RDBMS & Space Crunched String Comparison �� HSQLDBhsqldb��ʾ����ִ�Сд���ѯ�ģ� HSQLDBhsqldb RDBMS�Ŀռ���̫�տ���������ַ�Ƚ�
I previously discussed how to����ǰ��������� extend HSQLDB relational database�ӳ��� HSQLDBhsqldb����ʽ���Ͽ� with simple Java functions.���Java���ܡ� The example there actually implements case insensitive like query functionality for HSQLDB.������ʵ��ִ�в���ִ�Сд���ѯ�Ĺ��ܣ� HSQLDBhsqldb �� Read the�Ķ� article���� to get an understanding of how to write such custom functions and how to use them.��õ���ʶ�����д������Զ��幦�ܣ��Լ����ʹ�����ǡ� Then read below to find a solution for performing space crunched comparison of strings.Ȼ���Ķ������ҵ�һ���취��������ݿռ俴������ıȽ��ַ�
Space crunching of Strings is removing all spaces from a String, not just from the beginning and end as is done in trim().�ռ�ҵ�����ַ����������λ��һ���ַ���ֻ�Ǵӿ�ͷ�ͽ�β������������ �� �� This is often required when comparing business data from various sources.����������Ҫ���бȽ�ʱ��ҵ����ݴӸ�����Դ�� Here is a Java function to space crunch any String.������һ��Java�Ĺ��ܿռ�������κ��ִ���
public static String removeSpace(String target) { if(target == null) return null; return target.replace(" ", ""); } ������̬�ַ�removespace ���ַ���� �����Ŀ��==�գ����ؿ�;����target.replace �� �� �� �� �� �� �� ; �� You can use this function from HSQLDB RDBMS like this:�����ʹ�ô˹��ܣ� HSQLDBhsqldb RDBMS��������ģ�
select * from table_name where "com.taragana.Util.removeSpace"("column_name") = 'column_value' ѡ��*��table_name �� com.taragana.util.removespace �� �� �� column_name �� �� = ' column_value '
Note: The column_value passed should also be processed by removeSpace().ע�� column_valueͨ��ҲӦ����removespace �� �� ��
Note: Remember to escape the " with backslash when embedding in a Java String from a program.ע�⣺���ס�����ӡ��뷴б��ʱ��Ƕ����һ��Java�ַ��һ���ƻ���
The alternative to this is really painful.�����ʵ����ʹ��ġ� You will have to create a temporary table and process the data in code.�㽫���ò�����һ����ʱ���̵���ݣ����롣 Yet another reason to use HSQLDB?Ȼ����һ��ԭ��ʹ�ã� HSQLDBhsqldb �� I think it is the best and simplest low footprint super fast relational database management system.�Ҿ���������õĺ���ĵ��㼣����Ĺ�ϵ��ݿ����ϵͳ�� The strong Java integration is a bonus.ǿ���Java���ں���һ��� Can anyone point me how to do the same thing in Oracle?�κ��˶����Ե���������ͬ��������ڼ��ģ�
Filed under������ Database��ݿ� , �� Enterprise Software��ҵ��� , �� HSQLDB �� HSQLDBhsqldb , �� Headline Newsͷ������ , �� How To��� , �� J2EE J2EE�� , �� Java Software Java��� , �� Programming��� , �� RDBMS RDBMS�� , �� Tech Note����˵�� | |
| |
RSS 2.0 2.0 | |
Trackback Trackback���� this Article |������|
Email this Article�����ʼ�������
You may also like to read��Ҳ������� |



































