Thursday, April 21, 2011

Using Like in ibatis

when we use like operator, we normally need to do something like this

select * from t where t.name like 'saroj%'

we pass % at the end or beginning or both

if we had to do the same thing in IBatis using dynamic inputs then we can do following
select * from t where name like #name#||'%'

if we have a list of dynamic inputs then following would work

select * from t
where

name like #name[]#||'%'


this would generate following SQL:

select * from t where name like 'saroj%' or name like 'name1%' or name like 'name2%'

Thursday, April 07, 2011

How to develop critical thinking at early age

Critical Thinking is a must for a fulfilling life.

Question is: How do we build it? Well, this article gives good tip for building it in early childhood.

Key ideas are

1) Reason with your kid.

2) Classify ideas and share them with kid.

3) Build relationship between objects

4) Ask why, what if and why not?

5) Explore alternative ways

Monday, January 31, 2011

Eclipse Galileo and Helios won't update behind proxy

If you are trying to update Eclipse Galileo (3.5) and Helios (3.6) behind Proxy, you might run into problems like "Site is not found".

So, obvious course of action would be to check Proxy Configuration. Now, you change the settings and ensure that it has right authorization details.

Even after these steps, eclipse would fail to update and error message remains same.

It sounds baffling and it sure is.

After doing some googling for it, I found that Eclipse 3.5 onwards, FileTransferAPI has been changed. In ECF 3.0/Eclipse 3.5 the primary provider is based upon Apache httpclient 3.1. This was introduced in the ECF 3.0/Eclipse 3.5 cycle because the previous provider that was based upon the JRE URLConnection implementation proved insufficiently reliable (i.e. see bug 166179).

Unfortunately, the Apache httpclient implementation, although more robust than the URLConnection-based provider, does not support NTLMv2 proxies directly (for an explanation of why, see here).

For NTLMv2 Proxies, that require username and password for access the workaround is to

1. Disable the ECF httpclient provider.
2. Provide the NTLMv2 proxy authentication info (proxyhost, domain, username, and password)

In ECF 3.0/Galileo both can be done via system properties provided to Eclipse on startup. Here is an example using 'myproxy', 'mydomain', 'myusername', and 'mypassword':

Following settings can be put in eclipse.ini so that Eclipse does not use HTTPClient

-Dorg.eclipse.ecf.provider.filetransfer.excludeContributors=org.eclipse.ecf.provider.filetransfer.httpclient
-Dhttp.proxyPort=8080
-Dhttp.proxyHost=myproxy
-Dhttp.proxyUser=mydomain\myusername
-Dhttp.proxyPassword=mypassword
-Dhttp.nonProxyHosts=localhost|127.0.0.1


once you do this, you should be able to update Eclipse.

References:

  1. ECF Filetransfer Support for NTLMv2 Proxy
  2. Eclipse Bug about this problem

Tuesday, January 25, 2011

Setting up Apache Solr in Eclipse with Tomcat

Prerequisites for this exercise:
• Apache Solr 1.4.1 ( or some other release)
• Eclipse WTP
• Apache Tomcat 6.x

Steps are:

1. Extract Solr-1.4.1 release into C:\ Drive. For my example, directory is C:\apache-solr-1.4.1

2. Launch Eclipse and create a workspace, say solr-workspace

3. Import apache-solr-1.4.1.war file in your workspace by clicking on FIle -> Import,
Select Web --> War as the Import Source.
WAR File: C:\apache-solr-1.4.1\dist\apache-solr-1.4.1.war
Web Project: apache-solr-1.4.1
Click on Finish.






4. Create a folder called solr in the project and create another folder called conf inside solr as shown below:





5. Copy files from C:\apache-solr-1.4.1\client\ruby\solr-ruby\solr\conf into /solr/conf folder.
You can define your schema in schema.xml






6. Create a Tomcat Server using server wizard. Defaults would work fine.




7. Add project apache-solr-1.4.1 to your server as shown below


8. Edit server.xml to let tomcat know where are solr config files are:

<Context docBase="apache-solr-1.4.1" path="/apache-solr-1.4.1"
reloadable="true" source="org.eclipse.jst.j2ee.server:apache-solr-1.4.1">

<Environment name="solr/home" type="java.lang.String"
value="C:\myworkspaces\solr-workspace\apache-solr-1.4.1\solr" override="true"/>

</Context>

9. Start Server and you should see following

INFO: Using JNDI solr.home: C:\myworkspaces\solr-workspace\apache-solr-1.4.1\solr
INFO: Solr home set to 'C:\myworkspaces\solr-workspace\apache-solr-1.4.1\solr\'

Troubleshooting Tips

If your installation is showing errors that solr home is not found then do following
• ensure that server.xml is having right entry
• solr directory exists and has conf as child folder and all the files are there
• clean tomcat-server and clean tomcat work directory

Friday, January 07, 2011

Computer says no

Good read about how messy the computer systems are, at big banks.

As a result banks tend to operate lots of different databases producing conflicting numbers. “The reality was you could never be certain that anything was correct,” says a former executive at Royal Bank of Scotland. Reported numbers for the bank’s exposure were regularly billions of dollars adrift of reality, he reports; finding the source of the error was hard.

Saturday, March 06, 2010

Declarative Programming Vs Imperative Programming

principal distinction between declarative languages and imperative languages is that declarative languages allow the programmer to concentrate on the logic of an algorithm (declarative languages are goal driven, control is not the concern of the programmer), while imperative languages require the programmer to focus on both the logic and control of an algorithm.

Characteristics of imperative languages:

1. Model of computation based on a step by step sequences of commands.
2. Program states exactly how the result is to be obtained.
3. Destructive assignment of variables.
4. Data structures changed by successive destructive assignments.
5. Order of execution is crucial, commands can only be understood in context of previous computation due to side effects.
6. Expressions/definitions cannot be used as values.
7. Control is the responsibility of the programmer.

Characteristics of declarative languages:

1. Model of computation based on a system where relationships are specified directly in terms of the constituents of the input data.
2. Made up of sets of definitions or equations describing relations which specify what is to be computed, not how it is to be computed.
3. Non-destructive assignment of variables.
4. Explicit representations for data structures used.
5. Order of execution does not matter (no side effects).
6. Expressions/definitions can be used as values.

You can get more info here.

Tuesday, August 11, 2009

How to get MQ JMS Calls log

If you want to enable trace log for Websphere Java MQ and JMS Calls then you need to add following properties while starting tomcat/WAS/java program


-Djava.library.path="C:\WAS_MQ_LIB" It should be the path to the directory where mq related jars are available

-DMQJMS_TRACE_LEVEL="base" – it will do max logging

-DMQJMS_TRACE_DIR="c:\LOGS" – path to the directory where log should be written to

Thursday, July 30, 2009

Ibatis error: Error parsing XPath '/sqlMap/insert'. Cause: java.util.NoSuchElementException

If IBatis is throwing following exception then apart from usual suspects of correct dtd declaration in sql-map-config xml and sql-map xml files, one should also look at the insert sql definition in sql-map xml.

com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMap/insert'. Cause: java.util.NoSuchElementException

I had something like this in my insert query xml definition:
INSERT INTO TEST_T (ACCT_ID) VALUES (#acctId)

above mentioned sql statement throws com.ibatis.common.xml.NodeletException which is difficult to figure out.

In my case, error is due to not having closing hash (#) with acctId

If i change the insert statement to following then things work again, notice the closing # in #acctId#

INSERT INTO TEST_T (ACCT_ID) VALUES (#acctId#)

Hope that this is of some use to others who get this error.

Wednesday, July 22, 2009

150 is the limit of human brain!

This article from July/August 2009 issue of IEEE Security & Privacy states that based on research, it has been found that 150 is the limit of human brain to recognize other people, personally.

It has been this way forever and military formations also follow this rule and so do other tribes.

More can be read here.

Wednesday, May 27, 2009

How to fix Spring and MQ issue of Failed to convert property value of type [javax.naming.Reference] to required type [javax.jms.ConnectionFactory]

I ran into this exception and had to waste some hours to fix it. I was using Rational Application Developer 6 with Websphere MQ 5.3 to run a command line client. It should be valid for even higher versions of RAD and WMQ.

Exception is

org.springframework.beans.TypeMismatchException: Failed to convert property value of type [javax.naming.Reference] to required type [javax.jms.ConnectionFactory] for property 'targetConnectionFactory';

I hope that following will help others who run into this issue.

Steps you can take to solve this are:

1) Make sure that you have following jars in classpath:

* com.ibm.mq.jar
* com.ibm.mqbind.jar
* com.ibm.mqjms.jar
* ecutils.jar
* j2ee.jar
* messaging.jar
* messagingClient.jar
* messagingImpl.jar
* namingclient.jar

2) If above is there in classpath but you are still getting this error then check if you have conflicting version of jms related classes.

Sometimes, we have 2 different versions of jms.jar or jms related classes.

Make sure that you have right version of classes.

3) If you suspect class loading issue then use -verbose as a vm argument to see the classloading details.

See following article for RAD and JMS for more details.

Thursday, February 26, 2009

Using Java to Crack Office 2007

Using Java to Crack Office 2007 is a good article by Ted Neward - it shows how you can read word 2007 using plain java - thanks to new OOXML

Thursday, January 29, 2009

Finding out major mail servers of the world

This article is great about how to identify the mail servers, out there in the wild.

What is interesting is to look at mail server responses...

Tuesday, January 20, 2009

Physiological Basis of Yoga

Yoga is known to have done wonders for people. This article goes into some details to explain the physiological basis for this.

Wednesday, January 07, 2009

Code Quality: Coupling, Afferent and Efferent and Code Quality

All Software Projects deviate from their original design, as the time goes by. This is specially true
as code base gets bigger and new developers join in.

Maintaining the intention of design and keep things manageable, becomes tougher and tougher.

To handle this kind of situation, we need some support from Tools to properly understand
the coupling of code, their complexity and their test coverage. Without this information,
it is nearly impossible to know the cost of change in system.

Thankfully, we have JDepend which can help us deal with these kind of issues. It gives
us a measure of afferent (how many packages depend on you) and efferent coupling (how many
packages you depend on), Abstactedness, Instability.

Do read this article to know more about it.

Good news is that you can integrate this into your eclipse workspace too, via an eclipse plugin.

Saturday, January 19, 2008

Savour the historic moment of Triump of Determination and Will Power in Perth Cricket Test Match Jan 2008

Most of Indians felt cheated and humiliated by the end of Sydney Cricket Test Match in India's tour of Australia in Jan 2008.

Aussies got Mike Proctor - Match Referee from ICC to ban Harbhajan for 3 Test Matches. Indian team revolted and BCCI wilted under pressure. BCCI threatened to call of tour unless Bhajji was absolved of racial slur and Steve Bucknor (ever the nemesis of India) was relieved from umpiring in coming matches. ICC blinked and removed Bucknor off the tour and postponed Bhajji's hearing after the test series is over.

BCCI allowed the tour to go on and game was on for Perth,WACA. All pundits said that Shaun Tait and Lee would demolish INDIA but at the end of 4th day, 19 Jan 2008, India emerged victorious by defeating Aussie by 72 runs.

I have collected some of the best videos and writings about this match and here they are:

1) Ishant Sharma removed Ponting in both the innings and the way he did on day 4 was amazing
Ishant Sharma's heroics which removed Ponting on day 4

2) Without Warne, McGrath, Langer and Hayden - Aussie are weaker than ever
Australia's cracks finally exposed

3) Once again, India stopped Oz from creating the world record of 17 consecutive test matches - Last time, it was in KOLKATA 2001
India-Oz cricket rivalry revived

4) Watch awesome highlights here.


Awesome victory.... Satyamev Jayate.... (Truth prevails, against all odds)

Wednesday, July 18, 2007

Cookies and Firefox

It is bit mysterious the way FF stores cookies. It stores them in cookies.txt in Documents&Settings/User-Name/ApplicationData/Mozilla/Firefox/Profiles folder.

A Sample looks like this:

# HTTP Cookie File
# http://www.netscape.com/newsref/std/cookie_spec.html
# This is a generated file! Do not edit.
# To delete cookies, use the Cookie Manager.

.blogger.com TRUE / FALSE 1199862536 __utmz 150635877.

At times, we need Javascript to create cookies and manage them - more so when you are working with AJAX. So, refer to this article by PPK. It is useful.

Monday, July 02, 2007

Nasty Firefox 2/1.x ActiveX Error

Ever since I upgraded my FF to 2.0.x, I was getting nasty ActiveX Error which goes like this:

"active x error:
could not create the control {00000000-0000-0000-0000-000000000000}. Check that is has been installed on your computer and that this page correctly references it"

Fortunately, this tip saved my day. All it took to fix the errors was to update the npmozax.dll.

Anyone can download this from dlldump.com.


Friday, November 10, 2006

It is tough to be a Great Programmer

This article, called Law of Leaky Abstractions, by Joel is worth reading.

He articulates the issue very well.

Most Interesting Stuff is here...

The law of leaky abstractions means that whenever somebody comes up with a wizzy new code-generation tool that is supposed to make us all ever-so-efficient, you hear a lot of people saying "learn how to do it manually first, then use the wizzy tool to save time." Code generation tools which pretend to abstract out something, like all abstractions, leak, and the only way to deal with the leaks competently is to learn about how the abstractions work and what they are abstracting. So the abstractions save us time working, but they don't save us time learning.

And all this means that paradoxically, even as we have higher and higher level programming tools with better and better abstractions, becoming a proficient programmer is getting harder and harder.

Ten years ago, we might have imagined that new programming paradigms would have made programming easier by now. Indeed, the abstractions we've created over the years do allow us to deal with new orders of complexity in software development that we didn't have to deal with ten or fifteen years ago, like GUI programming and network programming. And while these great tools, like modern OO forms-based languages, let us get a lot of work done incredibly quickly, suddenly one day we need to figure out a problem where the abstraction leaked, and it takes 2 weeks. And when you need to hire a programmer to do mostly VB programming, it's not good enough to hire a VB programmer, because they will get completely stuck in tar every time the VB abstraction leaks.

The Law of Leaky Abstractions is dragging us down.

Sunday, September 17, 2006

Very good video of REC Trichy - Reminiscence

Very good video of REC Trichy - Reminiscence is available at google.

Eyes will become moist for sure and heart will ache once again for glory days....

Check it here.

Monday, July 24, 2006

All Dostoevsky said was 'we shall be with Christ.'

This article gave me some good idea about Dostoevsky's experiences in his early years.

Most revealing paragraph is:

As for Dostoevsky himself, though tortured by fear, he nevertheless held fast to that "philosophy" which the pervert Freud detested. As one of Dostoevsky's fellow conspirators on the scaffold recalled: "All Dostoevsky said was 'we shall be with Christ.'" Yes, Dostoevsky had Christian faith. Holy Bible faith. Hebrews Chapter 11 faith. In his moment of greatest fear the image of a waiting Christ sustained him, preserved his sanity. To the pervert Freud, this faith shackles man. But to the condemned man, the man facing his own grave, this faith is liberating.

Of course, history records that shortly after Dostoevsky uttered his famous words, just as the rifles were due to fire upon the first three, a reprieve was granted.