Indranil,
If your query is not returning any rows, it means you are supplying a "code" that does not exist in the TEACHERDATA table. (Or have I misunderstood your problem?)
In other words, perhaps the problem is with your SQL (and not with your
java).
Good Luck,
Avi.