I am trying to insert Date and time in a DATETIME type column through session.createSQLQuery() method and getting java.lang.NullPointerException.
Thanks in Advance.
Controller class Code:
    package dao;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.hibernate.Session;
import org.hibernate.Query;
import org.springframework.orm.hibernate3.HibernateTemplate;
public class AccountDAO {
    private HibernateTemplate template;
    Session session;
    int returnValue=0;
    public HibernateTemplate getTemplate() {
        return template;
    }
    public void setTemplate(HibernateTemplate template) {
        this.template = template;
    }
    public int insertLogoutTime(int srNum, String userName) {
        System.out.println("------>Inside AccountDAO<------");
        System.out.println("*************-- In insertLogoutTime() Method--************");
        try{
            SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date now = new Date();
            //System.out.println("update login_info set Logout_DateTime ='"+sdfDate.format(now)+"'" +" where SrNum= "+srNum+"");
            Query query=session.createSQLQuery("update login_info set Logout_DateTime =:theDate where SrNum=:srNum");
            query.setParameter("theDate", now);
            query.setParameter("srNum", srNum);
            returnValue= query.executeUpdate();
             System.out.println(returnValue);
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        return 0;
    }
}
Error:
17:50:21,167 ERROR [STDERR] java.lang.NullPointerException
 
     
    