Spiritual Reality – The Journey Within

Posted in Meditation | Tagged , , | Leave a comment

Lord Krishna reflects on how worrying about the future is unnecessary

On the basis of past experiences we imagine the joy and sorrow of the future.
To eliminate future sorrow we make plans today.
But Tomorrow’s hurdle if planned for today, does it benefit us or harm us? Continue reading

Posted in Motivational | Tagged , , , , , , , , , , , , , | 2 Comments

Enumerations in Java

Overview

Beginning with JDK 5, enumerations were added to the Java language, and they are now an integral and widely used part of Java. In their simplest form, Java enumerations appear similar to enumerations in other languages. However in Java, an enumeration defines a class type. By making enumerations into classes, the capabilities of the enumeration are greatly expanded. For example, in Java, an enumeration can have constructors, methods, and instance variables.

Continue reading

Posted in Tutorials | Tagged , , , , , , , | 3 Comments

Property Utility and Resource Bundle Utility

Contents

Continue reading

Posted in Tutorials | Tagged , , , , , , , , , , , , | Leave a comment

Java program to send mail to list of users (to list of carbon copy as well), with file attachment.

In project development we introduce communication module to communicate with customers, admin, users, and so on. The communication we use can be via mail and SMS functionality (as per the project requirement). Mail Functionality is very common and essential to send notifications, promotions, statements, invitations and so on. The program we creates to send mail should dynamic and easy maintainable so that communication should never cause issues.

Hence I have developed a program to send mail to list of users, a part of ‘To list’ or ‘CC list’ (BCC can also be added), with attachment (optional). This program can be configured with any mail server, just one has to configure it in properties file. Java Mail 1.4 dependency is used for communication helper. Continue reading

Posted in Utility & Helper | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

Singleton design pattern in java

Singleton pattern is one of the commonly used design solution. It describes a technique for ensuring that only a single instance of a class is ever created. In essence, the technique takes the following approach: don’t let anyone outside the class create instances of the class.

Singletons often control access to resources such as database connections or sockets. For example, if you have a license for only one connection for your database or your JDBC driver has trouble with multithreading, the Singleton makes sure that only one connection is made or that only one thread can access the connection at a time. If you add database connections or use a JDBC driver that allows multithreading, the Singleton can be easily adjusted to allow more connections.

There are many ways to achieve singleton in java, let us implement all possible approaches with common mistakes with solutions.
Continue reading

Posted in Tutorials | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

Java Program for getting all the modification of updated entity over existing entity.

In Java application we frequently use Hibernate. All the time when an application user modify/update its data then we save it into database and send message (SMS or Mail) to user about modification. For achieve this we retrieves existing entity from database and then compare with new entity. We follow this for each entity which results a huge number of classes or huge number of methods for comparison of each entity.
As we generally develop comparison program that does not work dynamically that is if new fields are added into entities then we modify comparison program again to cover new field. So now let us make a dynamic program for entity comparison which will be a common helper program for all entities rather than component specific.

Benefits of Program:

  1. Easy maintenance as it will be a common program for all entities and if entities are modified even then this program is no need to modify.
  2. No any additional jar required for entities comparison.
  3. Less time complexity.
  4. Reduced codes (number of classed and methods) as it is a common helper.

Limitations of Program:

  1. This program can be used only when the entities has primary key primitive type “id” Field (i.e. If primary key fields name is “iD” or “Id” or anything else apart from “id” then this program won’t work).
  2. This program work only with entities not with DTO, POJO or other classes.

Input for program:

  1. Two Objects of an entity (i.e. existing object and modified object).

Output of Program:

  1. Returns Map (String key, Object value), where key is [field Name _ Number or field Name _ New _ Number] and value is modified value.

Continue reading

Posted in Utility & Helper | Tagged , , , , , , , , | Leave a comment