Monday, August 11, 2008

Wasted Words Throw Away Power

“You don’t have to interfere in something that may not be any of your business. Just send a good thought and say, ‘Hello’ or ‘Can I help you?’” Reason: These words of encouragement or help ‘vibrate with positive force.’ Unkind words can devastate people or cause them to be disheartened or offended, cautions Browne


“Wasted words are a misuse of vital force. This throws away power. Energy is a sacred commodity and should be preserved. When we squander our energy we don’t have enough when we need it… The only way to preserve our energy is to watch our words.”


So many of our personal relationships are destroyed because of the way we speak to each other, rues the author. “Prepare your speech,” she advises. “We often speak with no preparation that results in thoughtless words.”


Rude, abrupt, mean, harsh, nasty, or crude remarks have harmful effects, explains Browne. “When combined with the speaker’s tone of voice, they create discordant vibrations. These thoughtless words live long after they are spoken and affect everyone within hearing distance.” She mentions as examples what we ubiquitously find: such as bosses who are rude or abrupt to employees in the morning and thus set the tone of the office for the whole day; and how ‘an upbeat, happy greeting can get the staff in a positive frame of mind resulting in a productive workday.’ More powerful than spoken words are the written ones. “If you say something and regret it, you can withdraw it with an apology. It is easy to forget exactly what someone said.” Not so with the written word. It is ‘indelibly imprinted.

Writing our thoughts down is a way to structure our thinking, the author guides.

“When we write a letter, we usually take more time to compose our thoughts than we do when we make a phone call. That is why people feel letters are special.”


On the positive side, she highlights how the written word can be creative and inspiring. “It can teach, guide, instruct, entertain, and shift our consciousness. It has a huge effect on getting the things that we want.” However, good writing takes focus, patience, and persistence, counsels Browne.


In sum, her message is simple and straight: “Be careful what you think. Be equally careful what you say. Be even more careful what you write.”

Recommended for a careful read.

Killer Instinct

Another Fabulous article by Madhav Mohan (http://MadhavMohan.com) on the Killer instinct.

On the sun-drenched veldt in Africa, a deadly drama of life and death is enacted daily. The lioness is on the hunt! She’s spotted her prey and is going for the kill! Ears flattened, body downwind, every muscle taut, all senses focused on the hapless wildebeest. Nothing registers in her consciousness except the prey. And then, a blur of frenzied movement followed by death cries: the wildebeest is meat for the pride.

Snapping up orders


On a lazy Saturday afternoon, the door chime signalling a visitor snapped Shabnam out of her reverie. As the store manager of a large retail furniture and furnishing outlet she is responsible for the store’s performance. She leads a team of 20 people and knows that every walk-in could be a huge sale. She homes in on the visitor and locks on! After 30 minutes, a sale worth Rs 4 lakh materialises. Shabnam has treated her prospect to coffee, established a strong rapport, answered every question and provided just the right solution.

In market after market, the drama is similar! The salesman spots the prospect and closes in for the sale. Total focus and single-pointed attention to clinch it! All faculties are tuned to the customer and his objections; every question is an opportunity to move a step closer to the consummation. And finally, the order is at hand!

Watching Shabnam in action, I’m struck by her resemblance to the lioness on the veldt! The same concentration and dedication and the same total commitment to the job at hand. Both have something in common: the killer instinct. A complete and irrevocable commitment to finish the job on hand, to close the circuit and achieve the result, under all conditions! No prey or prospect can ever slip away!


A must for every CEO



Every CEO must, of course, possess that killer instinct. More importantly, as a leader and organisation builder, he must look for people with this instinct in every functional area. That’s when the organisation is guaranteed to grow and prosper. Far too often, competence is blunted by the absence of the killer instinct and so opportunities simply evaporate. It’s somewhat like the hockey centre forward who dribbles past three defenders and the goal keeper only to shoot the ball wide off the mark! Many companies snatch defeat from the jaws of victory by entrusting important projects to people without the killer instinct.


Spot the trait


It’s difficult to spot the killer instinct, though. One key indicator is consistency. If a person has a record of consistent achievement in any field (academics, sport, previous assignments) it is quite likely that the achievement has been fuelled by the killer instinct. A second indicator is initiative: can the person think through and act quickly? And finally, if stamina and perseverance are present, the killer instinct could also lurk in the background.

The recruitment process must probe deeply into the background and psyche of the candidate. Career development and training programmes must build the capability to deliver results at all times. In today’s hyper competitive environment, there’s a premium on the killer instinct. Organisations that don’t institutionalise it are in danger of being devoured by those that do!

Friday, July 18, 2008

EJB Deployment Issue

I ran into this weird ejb deployment issue lately. It was a working EJB, then I had to add new remote methods to it. So I added them to the remote interface and to the actual java implementation class. Then when I deployed it locally, it some how doesnt seem to recognize my new methods, and when I access it, it simply throws NoSuchMethodFound error. After struggling for 1.5 days , (as though I dont have enough troubles..) figured out that I have an old client jar with the same .class file,(class I am trying to modify) and the server is picking up the classes from the lib folder evern before deploying my .class files in ejb-jar.

So server always tries to read files in the following order:
1) .class files from the lib folder
2) then any of classes in ur war files webroot/web-inf/classes folder

Also in EJB2.0, you dont need to create stubs and skeletons when you make changes and deploy your ear file,

Also when you provide a service jar to any of your remote service callers, all you porvide in the jar is

1) .class files with Home and Remote interfaces.
2) And no no stubs required. :)

You can generate this jar, by selecting the java classes in your eclipse rt click--> export as jar. I would recommned automate it in ur build file so you dont have to do it everytime. :)

-Coding Rocks.. !!!

Monday, July 14, 2008

SQL where Group by order by having

Writing Complex SQL and ordering.. squence in which the key words must be arranged to prevent SQL Command not properly ended error.


SELECT <> FROM
WHERE
GROUP BY
HAVING
ORDER BY


EXAMPLE:

SELECT P_OID,BASE_CR_FAC_ID,COUNT(*) FROM
V_A_FAC_P_ITEM
WHERE PROPOSAL_ITEM_APPR_STATUS_CODE = 'discarded'
GROUP BY BASE_C_FAC_ID,P_OID
HAVING COUNT(*) >1
ORDER BY P_OID desc


Further Reading: http://www.java2s.com/Code/SQL/Select-Clause/UsingmathfunctioninHAVING.htm
- SQL ROCKS..!!!

Wednesday, June 25, 2008

Spring JDBC - SQL with params

ex: String sql="select distinct PRIMARY_OWNER from "+xyzSchema+"v_rptg rptg"+
" where rptg.fac_id=:facId and " +
" (:cDate >= cit_eff_asof_dt and :cDate < cit_eff_until_dt) "
+ " and (:cDate >= en_eff_asof_dt and :cDate < en_eff_until_dt) ";

So now you'll hve to bind the highlighted variables in the query.

Object[] params = { facId,cDate, cDate, cDate, cDate};

To your query, pass in sql and the parameters bound (ex: for i/p parameter like :cDate in your query, params should contain a cDate in the same order as it expects in the query)

long clietnOid=queryForLong(sql,params);

Monday, June 23, 2008

Tokens in Struts

Purpose: To prevent a page from being re-submitted when user hits refresh or hits submit multiple times or user clicks on back / forward on your browser and hits submit again

Solution: Tokens in Struts 2.0

Token Methods:

The methods we care about are:

saveToken(HttpServletRequest req)
isTokenValid(HttpServletRequest req)
resetToken(HttpServletRequest req)

Once of the basic concept for implementing tokens:

1) Always provide a setupForInsertOrUpdate dispatch method or indvidual Action. You could also break it up into setupForInsert and setupForUpdate if you so desire. Regardless, make sure you always go through this Action method before you go to your form.
2) In your setup method make sure to call "saveToken(request)." This puts a unique key into Session scope and will cause this token to be placed on your resulting JSP.
In your Action's update/insert dispatch method or your Action's execute method, make sure to first check if "isTokenValid(request)." This compares the token in Session with the one submitted through the Request. If they match, the token is valid and it's ok to procede with the update/insert. If they do not match, the user is likely simply resubmitting a stale page so we return from our action immediately. We need to remember before we leave our update/insert method that we call "resetToken(request)" so that we place a new token into Session scope, otherwise the old token will remain and it will match the one on the form and will allow duplicate submisssions.


Example:

public ActionForward setUpForInsertOrUpdate(ActionMapping mapping,
ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
logger.debug("setUpForInsertOrUpdate");
saveToken(request);
EmployeeForm employeeForm = (EmployeeForm)form;
if (isUpdate(request, employeeForm)) {
Integer id = Integer.valueOf(employeeForm.getEmployeeId());
Employee employee = empService.getEmployee(id);
BeanUtils.copyProperties(employeeForm, employee);
}
prep(request);
return mapping.findForward(Constants.SUCCESS);
}



public ActionForward insertOrUpdate(ActionMapping mapping,
ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
logger.debug("insertOrUpdate");
EmployeeForm employeeForm = (EmployeeForm)form;
if ( !isTokenValid(request) ) {
return mapping.findForward(Constants.INVALID_TOKEN);
}
if (validationSuccessful(request, employeeForm)) {
Employee employee = new Employee();
BeanUtils.copyProperties(employee, employeeForm);
if (isUpdate(request, employeeForm)) {
logger.debug("update");
empService.updateEmployee(employee);
} else {
logger.debug("insert" );
empService.insertEmployee(employee);
}
populateEmployees(request);
resetToken(request);
return mapping.findForward(Constants.SUCCESS);
} else {
prep(request);
return mapping.findForward(Constants.FAILURE);
}
}


-Smile ...tokens are making your life easy :D

Friday, June 20, 2008

Running db scripts from command prompt

During development, we usually put all the sql scripts on a separate .sql file and run them at once, when you move your code on to other servers for testing purposes.

Here is how you run the scripts from the command prompt.


1) Open a command prompt at the folder where you have your sql scripts
2) execute sqlplus userid/pwd@srgtdev
3) above command will connect you to the oracle and give u a sql>
4) run the following
5) start filename.sql


woo huu all sqls in the batch file will be run successfully and you are good to go. here is an sample batch sql file

set echo on
spool 7_tpa_srgdbo_datascripts.sql.log

--set escape on

delete xyz where template_id in (-7);
INSERT INTO XYZ (TEMPLATE_ID, TEMPLATE_NAME, UPDATE_DATE, STATUS, TYPE, ASSESSMENT_TYPE_ID) VALUES (-7, 'FBI - Test7', SYSDATE, 'InActive', 'FBI', 1);

delete from XYZ_template where template_id = 999;

INSERT INTO XYZ_TEMPLATE (TEMPLATE_ID, TEMPLATE_NAME, UPDATE_DATE, STATUS, TYPE, ASSESSMENT_TYPE_ID, HANDLER_CLASS, HANDLER_JSP, HANDLER_PDF, HANDLER_TEMPLATE_TYPE) VALUES (999, 'Notch Template', SYSDATE, 'InActive', 'NOTCH', 1, 'com.xyz.say.service.Sample', '', '', '');

/* delete temporary data */
delete xyz_template where template_id in (-7);

----------- notching data script starts

delete from xyz_notching_template_qestn where template_id = 20001;

delete from xyz_assessment_type_value where assessment_value_id > 20000 and assessment_value_id < 20034;

delete from xyz_template where template_id = 20001;

delete from xyz_ASSESSMENT_TYPE where ASSESSMENT_TYPE_ID > 20000 and ASSESSMENT_TYPE_ID < 20016;



COMMIT;



spool off
set echo off


-Happy Coding Sonu