Posts

What is Liquibase ?

1.  Liquibase is an open source database-independent library for tracking, managing and applying database changes. 2. All changes to the database are stored in XML files and identified by a combination of an "id" and "author" tag as well as the name of the file itself. 3. A list of all applied changes is stored in each database which is consulted on all database updates to determine what new changes need to be applied. 4. Liquibase executes changes based on this XML file to handle different revisions of database structures and data. 5. When you first run a changelog, LiquiBase manages those changelogs by adding two tables into your database. databasechangelog : maintains the database changes that were run. databasechangeloglock : ensures that two machines don't attempt to modify the database at one time. 6. Limitations do exist such that it will not export triggers, stored procedures, functions and packages. Sample changeLog file:  The above is...

How to integrate Liquibase with Spring and Hibernate ?

Image
A sample tutorial on how to integrate Liquibase with Spring and Hibernate. While writing this tutorial, I have added javadoc in the code for better understanding and I believe You already have good knowledge on Spring and Hibernate. The main motto of this tutorial is to give an idea on how you can integrate Liquibase with Spring and Hibernate. If you are new to Liquibase : Click Here To integrate liquibase into your project, you need liquibase jars, So  download it before starting the project. I have created an application named "SHLIntegration". The Structure of the project is as follows : The dependencies are also listed here: Lets start with Employee class : 1. Create Employee class having getter/setter and add proper JPA annotation to each variable as below.   public class Employee {     @Id     @GeneratedValue     @Column(name="EMPLOYEE_ID")     private long id;     @Column...

Some ANT task

1. How to build  project from another build. <target name="project2"             description="Builds project2 project, required depedency">         <!-- Build project2 first  -->         <subant target="dist" verbose="yes" inheritall="false">             <filelist dir="../com.waheed.project2"                       files="build.xml" />         </subant>     </target>   2. How to read SVN revision and write into some file <loadfile property="revision" srcFile="./.svn/entries">         <filterchain>           ...

Spring MVC tutorial

Before Starting, I believe you must have basic idea about JAVA, SPRING and Spring MVC. For Spring MVC : http://waheedtechblog.blogspot.in/2012/08/spring-mvc.html In this tutorial , I will just tell you what are the basic thing that you need to start MVC. Step 1 : Create a class  @Controller public class HelloWorld {        @RequestMapping ( "/hello" )      public String helloWorld() {           return = "Hello World, Spring 3.0!" ;      } } 1 . The class HelloWorld  has the annotation @Controller and @RequestMapping("/hello") . When Spring scans this class, it will recognize this bean as being a Controller bean for processing requests. 2 .The @RequestMapping annotation tells Spring that this Controller should process all requests beginning with /hello in the URL path. Step 2. Mapping Spring MVC in WEB.xml The entry point of Spring 3...

Spring MVC

Image
Spring MVC helps in building flexible and loosely coupled web applications. The Model-view-controller design pattern helps in seperating the business logic, presentation logic and navigation logic. Models are responsible for encapsulating the application data. The Views render response to the user with the help of the model object . Controllers are responsible for receiving the request from the user and calling the back-end services. When a request is sent to the Spring MVC Framework the following sequence of events happen. The DispatcherServlet first receives the request. The DispatcherServlet consults the HandlerMapping and invokes the Controller associated with the request. The Controller process the request by calling the appropriate service methods and returns a ModeAndView object to the DispatcherServlet . The ModeAndView object contains the model data and the view name. ...

Sending Email Via JavaMail API Example

From last one month, My internet device is missing from my terrace. So, Mostly I use mobile to access my mail but accessing mail via mobile is very irritating thing because of the slow bandwidth. To send one single mail I have to wait till the mailbox get opened. This is very simple way to send mail without opening your account. :) This is the example to show you how to use JavaMail API method to send an email via Gmail SMTP server. You need mail.jar library to run this code. import java.util.Properties; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.PasswordAuthentication; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; /**  * @author abdul  *  */ public class SendEmail {     public static void main(String[] args) {                 final String username="YOUR_USER_NAME"...

Spring Auto-Wiring Beans with @Autowired annotation

In Spring, you can use @Autowired annotation to auto wire bean on the setter method, constructor or a field. There are two ways to can achieve it : 1.Using <context:annotation-config />     Just Add Spring context and <context:annotation-config /> in bean configuration file <beans xmlns="http://www.springframework.org/schema/beans"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"     xmlns:tx="http://www.springframework.org/schema/tx"     xmlns:context="http://www.springframework.org/schema/context"     xsi:schemaLocation="http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd     http://www.springframework.org/schema/aop     http://www.springframework.org/schema/aop/spring-aop.xsd     http://www.springframework.org/sche...