weird naming convention of substring() method of java.lang.String class

The substring() method of java.lang.class is not inline with the Java naming conventions for methods.

As per Java naming conventions, all the methods will be in camelCase.But this does not bother substring() method.

To get sub string of any string in Java, we should use substring() NOT subString().

PS: I remember there are some other capitalization styles other than camelCase and PascalCase but could not recollect them at this moment.

The following Error related to JBoss Drools frustrated me because of Java Version mismatch.

The version of Drools we are using runs properly only with JDK 1.5 where as we are trying hard to make it run on JDK1.6 and ended up with the following issue.


java.lang.ClassNotFoundException: [Lorg.drools.rule.Declaration;

at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa

der.java:1359)

at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa

der.java:1205)

at org.drools.rule.PackageCompilationData$PackageClassLoader.loadClass(U

nknown Source)

at java.lang.ClassLoader.loadClass(ClassLoader.java:251)

at org.drools.common.ObjectInputStreamWithLoader.resolveClass(Unknown So

urce)

at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:157

5)

at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)

at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1624)

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)

at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:19

45)

at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1869)

at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1

753)

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)

at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)

at java.util.HashMap.readObject(HashMap.java:1029)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.

java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces

sorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974

)

at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1846)

at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1

753)

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)

at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)

at org.drools.rule.PackageCompilationData.readExternal(Unknown Source)

at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:179

2)

at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1

751)

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)

at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)

at org.drools.rule.Package.readExternal(Unknown Source)

at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:179

2)

at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1

751)

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)

at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)

at java.util.HashMap.readObject(HashMap.java:1029)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.

java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces

sorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974

)

at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1846)

at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1

753)

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)

at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)

at org.drools.common.AbstractRuleBase.doReadExternal(Unknown Source)

at org.drools.reteoo.ReteooRuleBase.readExternal(Unknown Source)

at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:179

2)

at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1

751)

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)

at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)

at com.infosys.ipsp.ade.impl.RuleBaseRepositoryImpl.deSerializeRuleBase(

RuleBaseRepositoryImpl.java:73)

at com.infosys.ipsp.ade.impl.RuleBaseRepositoryImpl.deSerializeRuleBase(

RuleBaseRepositoryImpl.java:85)

at com.infosys.ipsp.ade.userinteraction.ConsultationServlet.doGet(Consul

tationServlet.java:108)

at com.infosys.ipsp.ade.userinteraction.ConsultationServlet.doPost(Consu

ltationServlet.java:70)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl

icationFilterChain.java:269)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF

ilterChain.java:188)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV

alve.java:210)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV

alve.java:174)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j

ava:127)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j

ava:117)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal

ve.java:108)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav

a:151)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java

:870)

at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p

rocessConnection(Http11BaseProtocol.java:665)

at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo

int.java:528)

at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFol

lowerWorkerThread.java:81)

at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP

ool.java:685)

at java.lang.Thread.run(Thread.java:619)

MS SQL Server 2K and Win XP

MS SQL Server 2000 Enterprise Edition Server componentscan not be installed on Windows XP.

Only client components can be installed.

I am exploring how to install Personal Edition on Win XP.I thought I will post it after I successfully do it.But we again did not use it and got the work done with Enterprise Edition.So this is the end of Personal Edition.

At last, we successfully deployed ASP web application.Some interesting findings:

[1] Our application can be installed on MS SQL Server 2000 Enterprise Edition ( I did) or Developer Edition (I did) or Personal Edition(I saw Gaurav Deshmukh did).

[2] Deploying ASP Web Application in IIS is easy.

[3] The whole issue started because we were trying very hard to make the user we created own our tables instead of letting those tables owned by standard “dbo” user of SQL Server.And we tried to connect with the same user we created instead of connecting to SQL Query Analyzer tool with standard “sa” user of SQL Server.

so the guy who helped us did these:

[1] Run the table creation script by standard “sa” user.
[2] So that, all the created tables will be owned by “dbo” user.
[3] Now we can create any custom user of our choice and all that we have to do is just associate this custom user with the above created database. Then we can use this custom userid and password in our configuration files(in our case it is qdo.asp) to connect to the database.

This is my first encounter with Microsoft technologies like IIS, SQL Server 2000 and ASP.

Java’s Checked and Unchecked Exceptions- demystified

Until recently, I had hard time remembering what is the difference between checked and unchecked exceptions.

Finally Head First Java gave me the prompt explanation. Here it goes:

Checked Exceptions: Arise due to the reasons which are beyond control of programmer so complier mandates them to handle or declare.

Unchecked Exceptions: Arises due to logic flaws in the code.So these should be eliminated.Exception Handling mechanism is not supposed to take care of programmer injected logic flaws in the code.So complier wont bother.It is the responsibility of the programmer to eliminate them.

I am also looking for similar kind of prompt and clear explanation for the difference between Error and Exception.If you get to know, I appreciate if you can share with me.

Diwali — Friday,09-November-2007

We had a very good time for this Diwali in Hyderabad.Three days disappeared so fast :-((
Reached Hyderabad on Friday.Spent most of the time at home.Met Chiru.And evening with crackers.

Saturday went to Chilkur Balaji Darshan.Darshan went very well.Met Sriniwas unexpectedly at Spencers in Miyapur when me and bobby were busy searching for something.Night Pav Bhaji at Lakshmi aunt’s home.

Sunday went busy with packing up our luggage.

Same MMTS and same Kacheguda Express. We were in Bangalore this morning.

This Diwali was definitely not like many other Diwalis I spent in the past.

And I am very sure, future Diwalis will be much more brightful for us.

JScrollPane for JTextBox

I was creating a GUI using Java Swings.

I decided to add a text box with vertical scroll bar to it. I also have few more other components to be added and my text box with scroll bar comes after some of them.

So I started adding one by one,

panel.add(dateLabel);
panel.add(dateTextbox);
…..

//now the turn of description text box

panel.add(descriptionTextbox);
panel.add(scrollbarForDescriptionTextbox);
……

I compiled and ran the program. The output was weird.The descriptionTextbox is coming without scrollbar and as I continue hitting ENTER in it, it is expanding and exceeding even the frame size.And my poor scrollbarForDescriptionTextbox is lying idly next to the descriptionTextbox .

I was surprised why it is happening like this and kept looking at the code over and over again. I spent sometime even yesterday night before going to bed.But I couldn’t get it.

Today morning at 5:30 I just opened my laptop to see it again. I found the mistake I did in less than 2 minutes.

Here is the catch:

Initially I said ,

JScrollPane scrollbarForDescriptionTextbox = new JScrollPane(descriptionTextbox);

now that I created scroll bar for descriptionTextbox,I should only say

panel.add(scrollbarForDescriptionTextbox);

instead, I said

panel.add(descriptionTextbox);
panel.add(scrollbarForDescriptionTextbox);

which is a blooper! Though its OK for compiler, I didn’t get my expected output.

Refreshing Re-union

Yesterday being Kannada Rajyotsava, hence holiday for all the offices and also Srihari wanted to treat all of us for his H1, so we 4 – Theja, Sudhakar, Srihari and Me – decided to meet after a long time at China Pearl in Koramangala.I joined Sudhakar at his house in BTM and we both went by bike.Srihari came by bus and Theja by Auto.After few “chakkars” on bike on the streets f Koramangala, we could at last found the restaurant next to Vijaya Bank in Koramangala.The ambiance is good.Being Thursday, I accompanied Theja for veg. So I cant comment on non-veg food. As per feedback from Srihari and Sudha, I figured out that their food didn’t impress them much.But I liked veg food.It tasted decent enough and so is its appeal to my eyes.

After that we went to Corner House for ice cream and gulped in ice creams worth 250/-.Then headed on to Forum Mall, spent sometime window shopping in Westside, Pepe, Tommy Hilfiger, Adidas and Nike showrooms. I really wanted to buy one shirt but nothing impressed me.Then sat on the platform behind Fabmall, took some snaps.Then decided to go to IIM for more picturesque locations for our snaps.

I was very much delighted when Sudhakar made me hear the funny interview I gave him in 2004 June, when I was desperately searching for a job. I am glad that he still preserved it.

At IIM, we took so many snaps in the lawns, forests,corridors and Auditoriums using all our creativity and at last settled down at CCD for some frappe. Then spent time chatting till 9 PM and dispersed.

It has been a very refreshing for me to reunion with my best friends, college-time roomies and buddies.

It is high time I realized the advantages of not being forgotten.Hence I decided to enter Orkut again. As I read some where, Network is net worth!

Tricky RESET

In HTML, reset is used to well reset the form.This means the form will be reverted to the way it was as soon as it got loaded. Here are 2 important cases.

[1] You loaded an empty form which has some fields like text boxes, check boxes, combos etc.
So when you hit on reset, as per the above definition of reset, all these fields will be reverted to the way they were as soon as the form got loaded. That means, all the fields get blank values.

[2] Assume your form has two text boxes, and two combos which I call textbox1, textbox2, combo1 and combo2 in the same order.Now the form is coded such that the values to be loaded in combo2 depends on the value selected in combo1.Very prevalent in many web applications.

Now you started filling the form, entered some text in textbox1 and textbox2, selected some value in combo1 and combo2 got loaded accordingly.Now you changed your mind and hit on reset button to reset the form but you see that the form didn’t get reset and the old values are still there in the fields. why?

The trick is this: read the definition of reset again. It will revert the form to the way it was as soon as it got loaded.Hope now you understood why it happened like that.If not, please read on.

As soon as you select some value in combo1, the form gets submitted to get the values in combo2.That means , the form is loaded again. So by the time you hit the reset button, the loaded form is not the one which has blank values for all it’s fields but the one with some text in in textbox1, textbox2 and combo1.And reset button has reset the form to that state.So what is the workaround?

Just don’t use the HTML provided reset button. Instead code your own reset button which sets the fields to blank values.

Code may look some thing like below:

DONT use

<input type=”reset” >

Instead use

<input type=”button” onclick=”ResetForm()”>

Code for ResetForm() may look something like this:

<script type=”text/javascript”></script>
function ResetForm()
{
document.yourForm.name.value = “”;
document.yourForm.description.value = “”;
document.yourForm.projectId.selectedIndex =0;
document.yourForm.projectId.disabled =true;
document.yourForm.comments.value = “”;
document.yourForm.name.focus();
}
</script>