java4all@1986 java. Powered by Blogger.

Top Ten Exceptions in Java?

>> Sunday, May 22, 2011

  1. Null Pointer Exception Exception
Assigning null to an object.
EXAMPLE:
String s-null;

2.Stack Overflow error

If we are performing recursive method invocation
Example:
class Test{

public void m1()
{
m1();
}
public static void main(String args[])
{
m1();

}


}

3.ArrayIndexOutOfBound Exception
If we are assigning a value to an array which is out of it's range

EXAMPLE:
int[] a={10,20,89,60}
System.out.println(a[2]); o/p is==89;
System.out.println(a[5]); o/p AIOBE;

4.) ClassCastException
It occurs when we are trying to typecast parent class object to child type

5.) NoclassDefFoundError
If the required class is not found available
Ex:
Java A and enter
If a.class file is not available we will get NCDFE

6.ExceptionInInitializerError
Whenever an Exception occurred during Initialization of static variables (or) static blocks.
EX:
class Test
{
static int i=10/0;
}

output :
EIIE caused by AritmeticException/by Zero

7.)IllegalArgumentException
If we are trying to invoke set priority method with more than it's range
EX:
class Test{
public static void main(String args[])
{
Thread.currentThread.setPriority(100);
}
}

8.) NumberFormatException
We are attempting to convert string to number type,if string is not formatted properly
EX:
String s="10";
int i=Integer.parseInt(s) o/p===10;

String s="ten";
int i=Integer.parseInt(s); o/p is NFE

9.)IllegalStae Exception

If thread is started and we again start the thread it raises ISE

10.)Assertion Exception

Read more...

Top Ten Exceptions In Java?

Read more...

How To Retrevie Data from Database using struts and hibernate integration?

Create A Jsp page With One Field Employeecode and Month?.
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
  
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>SEARCH EMPLOYEE DATA BASED ON EMPLOYEE CODE </title>
</head>
<body background="blue">
<jsp:include page="header.jsp"></jsp:include>
<html:form action="/search">

<center><font size="5" colour="blue">SEARCH EMPLOYEE DATA BASED ON EMPLOYEE CODE AND MONTH</font></center>
<center>
<table bgcolor="blue" cellpadding="2" cellspacing="0">

<tr>
<td>Search BY EmpCode:
<html:text property="empcode" /></td></tr>
<br><br><br>
<tr>
<td>Month:
<html:select property="umonth">
<html:option value=" ">   </html:option>
<html:option value="JANUARY">JANUARY</html:option>
<html:option value="FEBUARY">FEBUARY</html:option>
<html:option value="MARCH">MARCH</html:option>
<html:option value="APRIL">APRIL</html:option>
<html:option value="MAY">MAY</html:option>
<html:option value="JUNE">JUNE</html:option>
<html:option value="JULY">JULY</html:option>
<html:option value="AUGUST">AUGUST</html:option>
<html:option value="SEPTEMBER">SEPTEMBER</html:option>
<html:option value="OCTOBER">OCTOBER</html:option>
<html:option value="NOVEMBER">NOVEMBER</html:option>
<html:option value="DECEMBER">DECEMBER</html:option>
</html:select>
</td>
<td>-YEAR-:
<html:select property="uyear">
<html:option value=" "></html:option>>
<html:option value="1980">1980</html:option>
<html:option value="1981">1981</html:option>
<html:option value="1982">1982</html:option>
<html:option value="1983">1983</html:option>
<html:option value="1984">1984</html:option>
<html:option value="1985">1985</html:option>
<html:option value="1986">1986</html:option>
<html:option value="1987">1987</html:option>
<html:option value="1988">1988</html:option>
<html:option value="1989">1989</html:option>
<html:option value="1990">1990</html:option>
<html:option value="1991">1991</html:option>
<html:option value="1992">1992</html:option>
<html:option value="1993">1993</html:option>
<html:option value="1994">1994</html:option>
<html:option value="1995">1995</html:option>
<html:option value="1996">1996</html:option>
<html:option value="1997">1997</html:option>
<html:option value="1998">1998</html:option>
<html:option value="1999">1999</html:option>
<html:option value="2000">2000</html:option>
<html:option value="2001">2001</html:option>
<html:option value="2002">2002</html:option>
<html:option value="2003">2003</html:option>
<html:option value="2004">2004</html:option>
<html:option value="2005">2005</html:option>
<html:option value="2006">2006</html:option>
<html:option value="2007">2007</html:option>
<html:option value="2008">2008</html:option>
<html:option value="2009">2009</html:option>
<html:option value="2010">2010</html:option>
<html:option value="2011">2011</html:option>
<html:option value="2012">2012</html:option>
<html:option value="2013">2013</html:option>
<html:option value="2014">2014</html:option>
<html:option value="2015">2015</html:option>
<html:option value="2016">2016</html:option>
<html:option value="1980">1980</html:option>
</html:select></td>

</tr>
<tr>
<td align="center"><html:submit value="SEARCH"/></td></tr><br><br></br>
</table></center>
</html:form>

<logic:present name="searchresults" >

<table border="1">
<tr>
<td>emp_info_audit_key</td>
<td>empcode</td>
<td>empname</td>
<td>emp_designation</td>
<td>emp_department</td>
<td>emp_bank_acc_no</td>
<td>emp_email</td>
<td>emp_no_ofdays_worked</td>
<td>emp_basic</td>
<td>emp_hra</td>
<td>emp_conveyance</td>
<td>emp_onsite_allowence</td>
<td>emp_medical</td>
<td>emp_pf_emp_con</td>
<td>emp_gross</td>
<td>emp_pf</td>
<td>emp_itax</td>
<td>emp_pro_tax</td>
<td>emp_other_deduct</td>
<td>emp_tot_deduct</td>
<td>emp_net_sal</td>
<td>date_time</td>
<td>month_salary</td>
<td>create_user</td>
<td>modify_user</td>
</tr>
</table>
<table border="1" bgcolor="blue">
<logic:iterate id="reportSearch" name="searchresults" scope="session">
<tr>
<td><bean:write property="emp_info_audit_key" name="reportSearch"/></td>
<td><bean:write property="empcode" name="reportSearch"/></td>
<td><bean:write property="empname" name="reportSearch"/></td>
<td><bean:write property="emp_designation" name="reportSearch"/></td>
<td><bean:write property="emp_department" name="reportSearch"/></td>
<td><bean:write property="emp_bank_acc_no" name="reportSearch"/></td>
<td><bean:write property="emp_email" name="reportSearch"/></td>
<td><bean:write property="emp_no_ofdays_worked" name="reportSearch"/></td>
<td><bean:write property="emp_basic" name="reportSearch"/></td>
<td><bean:write property="emp_hra" name="reportSearch"/></td>
<td><bean:write property="emp_conveyance" name="reportSearch"/></td>
<td><bean:write property="emp_onsite_allowence" name="reportSearch"/></td>
<td><bean:write property="emp_medical" name="reportSearch"/></td>
<td><bean:write property="emp_pf_emp_con" name="reportSearch"/></td>
<td><bean:write property="emp_gross" name="reportSearch"/></td>
<td><bean:write property="emp_pf" name="reportSearch"/></td>
<td><bean:write property="emp_itax" name="reportSearch"/></td>
<td><bean:write property="emp_pro_tax" name="reportSearch"/></td>
<td><bean:write property="emp_other_deduct" name="reportSearch"/></td>
<td><bean:write property="emp_tot_deduct" name="reportSearch"/></td>
<td><bean:write property="emp_net_sal" name="reportSearch"/></td>
<td><bean:write property="date_time" name="reportSearch"/></td>
<td><bean:write property="month_salary" name="reportSearch"/></td>
<td><bean:write property="create_user" name="reportSearch"/></td>
<td><bean:write property="modify_user" name="reportSearch"/></td>

</tr>
</logic:iterate>
</table>
</logic:present>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<jsp:include page="footer.jsp"></jsp:include>
</body>
</html>


Crate An Action Fom Class?
public class SearchForm extends ActionForm {
private String empcode=null;
private String umonth=null;



/**
* @return the umonth
*/
public String getUmonth() {
return umonth;
}
/**
* @param umonth the umonth to set
*/
public void setUmonth(String umonth) {
this.umonth = umonth;
}
/**
* @return the empcode
*/
public String getEmpcode() {
return empcode;
}
/**
* @param empcode the empcode to set
*/
public void setEmpcode(String empcode) {
this.empcode = empcode;
}
/**
* @return the month
*/


}


Create An ActionClass?
public class SearchAction extends Action{
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
// TODO Auto-generated method stub
SearchForm objSearchForm=(SearchForm)form;
String empcode=objSearchForm.getEmpcode();
String month=objSearchForm.getUmonth();

System.out.println("in search action class");

try{

DaoFactory daoFactory=new DaoFactory(); //(It is a Foctory class)//
ReportSearchDao dao=daoFactory.getReportSearchDaoImpl();

ArrayList al= dao.searchResults(objSearchForm);


HttpSession objHttpSession = request.getSession();

if(objHttpSession.getAttribute("searchresults") != null)
{
objHttpSession.removeAttribute("searchresults");
}

if( al.size()>0)
{
objHttpSession.setAttribute("searchresults", al);
}
System.out.println("inside try block");



}catch(Exception e)
{
e.printStackTrace();
System.out.println("error in action class");
}
return mapping.findForward("success");
}

}
Craate A factory class ?
A Factory class which retrun object of the implemented class.
public class DaoFactory {
public ReportSearchDao getReportSearchDaoImpl(){

return new ReportSearchDaoImpl();
}


}

Craete A Dao Interface?
Here we will provide a Abstractmethod ..
public interface ReportSearchDao {
public ArrayList searchResults(SearchForm objSearchForm) throws Exception;

}
Craete DaoImpl Class?
package com.centris.atr.dao.pojos;

import java.util.ArrayList;
import java.util.Iterator;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;

import com.centris.atr.dao.sessionfactory.HibernateSessionFactory;
import com.centris.atr.dto.ReportSearch;
import com.centris.atr.struts.formbean.SearchForm;

public class ReportSearchDaoImpl implements ReportSearchDao {
Session session=null;
ArrayList al;

public ArrayList searchResults(SearchForm objSearchForm) throws Exception
{
try{
SearchForm objSearchForm1=new SearchForm();
String empcode=objSearchForm.getEmpcode();
System.out.println("dao empcode"+empcode);
String month=objSearchForm.getUmonth();
System.out.println("month"+month);
al=new ArrayList();
session=HibernateSessionFactory.getSession();
System.out.println("===============1===============");
System.out.println("session"+session);
Query query=session.createQuery("from AtrEmployeeInfo where empcode=? and month_salary=?").setString(0, empcode).setString(1, month);
Iterator it=query.iterate();
while(it.hasNext())
{
AtrEmployeeInfo atrEmployeeInfo=it.next();
System.out.println("emp_info_audit_key======"+atrEmployeeInfo.getEmp_info_audit_key()+"empcode======"+atrEmployeeInfo.getEmpcode()+"empname======="+atrEmployeeInfo.getEmpname()+"emp_designation====="+atrEmployeeInfo.getEmp_designation()+"emp_department"+atrEmployeeInfo.getEmp_department()+"emp_bank_acc_no======="+atrEmployeeInfo.getEmp_bank_acc_no()+"emp_email"+atrEmployeeInfo.getEmp_email()+"emp_no_ofdays_worked========"+atrEmployeeInfo.getEmp_no_ofdays_worked());
ReportSearch reportSearch=new ReportSearch();
reportSearch.setEmp_info_audit_key(atrEmployeeInfo.getEmp_info_audit_key());
reportSearch.setEmpcode(atrEmployeeInfo.getEmpcode());
reportSearch.setEmpname(atrEmployeeInfo.getEmpname());
reportSearch.setEmp_designation(atrEmployeeInfo.getEmp_designation());
reportSearch.setEmp_department(atrEmployeeInfo.getEmp_department());
reportSearch.setEmp_bank_acc_no(atrEmployeeInfo.getEmp_bank_acc_no());
reportSearch.setEmp_email(atrEmployeeInfo.getEmp_email());
reportSearch.setEmp_no_ofdays_worked(atrEmployeeInfo.getEmp_no_ofdays_worked());
reportSearch.setEmp_basic(atrEmployeeInfo.getEmp_basic());
reportSearch.setEmp_hra(atrEmployeeInfo.getEmp_hra());
reportSearch.setEmp_conveyance(atrEmployeeInfo.getEmp_conveyance());
reportSearch.setEmp_onsite_allowence(atrEmployeeInfo.getEmp_onsite_allowence());
reportSearch.setEmp_medical(atrEmployeeInfo.getEmp_medical());
reportSearch.setEmp_pf_emp_con(atrEmployeeInfo.getEmp_pf_emp_con());
reportSearch.setEmp_gross(atrEmployeeInfo.getEmp_gross());
reportSearch.setEmp_pf(atrEmployeeInfo.getEmp_pf());
reportSearch.setEmp_itax(atrEmployeeInfo.getEmp_itax());
reportSearch.setEmp_pro_tax(atrEmployeeInfo.getEmp_pro_tax());
reportSearch.setEmp_other_deduct(atrEmployeeInfo.getEmp_other_deduct());
reportSearch.setEmp_tot_deduct(atrEmployeeInfo.getEmp_tot_deduct());
reportSearch.setEmp_net_sal(atrEmployeeInfo.getEmp_net_sal());
reportSearch.setDate_time(atrEmployeeInfo.getDate_time());
reportSearch.setMonth_salary(atrEmployeeInfo.getMonth_salary());
reportSearch.setCreate_user(atrEmployeeInfo.getCreate_user());
reportSearch.setModify_user(atrEmployeeInfo.getModify_user());
al.add(reportSearch);
}

System.out.println("after query");




}catch(HibernateException e)
{
e.printStackTrace();

}
finally
{
session.close();
}

System.out.println("above return");
return al;


}


}


Create a Dto Class?
public class ReportSearch {
private Integer emp_info_audit_key;
private String empcode;
private String empname;
private String emp_designation;
private String emp_department;
private String emp_bank_acc_no;
private String emp_email;
private Integer emp_no_ofdays_worked;
private Integer emp_basic;
private Integer emp_hra;
private Integer emp_conveyance;
private Integer emp_onsite_allowence;
private Integer emp_medical;
private Integer emp_pf_emp_con;
private Integer emp_gross;
private Integer emp_pf;
private Integer emp_itax;
private Integer emp_pro_tax;
private Integer emp_other_deduct;
private Integer emp_tot_deduct;
private Integer emp_net_sal;
private Date date_time;
private String month_salary;
private String create_user;
private String modify_user;




public Integer getEmp_info_audit_key() {
return emp_info_audit_key;
}
public void setEmp_info_audit_key(Integer emp_info_audit_key) {
this.emp_info_audit_key = emp_info_audit_key;
}

public String getEmpcode() {
return empcode;
}
public void setEmpcode(String empcode) {
this.empcode = empcode;
}
public String getEmpname() {
return empname;
}
public void setEmpname(String empname) {
this.empname = empname;
}
public String getEmp_designation() {
return emp_designation;
}
public void setEmp_designation(String emp_designation) {
this.emp_designation = emp_designation;
}
public String getEmp_department() {
return emp_department;
}
public void setEmp_department(String emp_department) {
this.emp_department = emp_department;
}
public String getEmp_bank_acc_no() {
return emp_bank_acc_no;
}
public void setEmp_bank_acc_no(String emp_bank_acc_no) {
this.emp_bank_acc_no = emp_bank_acc_no;
}
public String getEmp_email() {
return emp_email;
}
public void setEmp_email(String emp_email) {
this.emp_email = emp_email;
}
public Integer getEmp_no_ofdays_worked() {
return emp_no_ofdays_worked;
}
public void setEmp_no_ofdays_worked(Integer emp_no_ofdays_worked) {
this.emp_no_ofdays_worked = emp_no_ofdays_worked;
}
public Integer getEmp_basic() {
return emp_basic;
}
public void setEmp_basic(Integer emp_basic) {
this.emp_basic = emp_basic;
}
public Integer getEmp_hra() {
return emp_hra;
}
public void setEmp_hra(Integer emp_hra) {
this.emp_hra = emp_hra;
}
public Integer getEmp_conveyance() {
return emp_conveyance;
}
public void setEmp_conveyance(Integer emp_conveyance) {
this.emp_conveyance = emp_conveyance;
}
public Integer getEmp_onsite_allowence() {
return emp_onsite_allowence;
}
public void setEmp_onsite_allowence(Integer emp_onsite_allowence) {
this.emp_onsite_allowence = emp_onsite_allowence;
}
public Integer getEmp_medical() {
return emp_medical;
}
public void setEmp_medical(Integer emp_medical) {
this.emp_medical = emp_medical;
}
public Integer getEmp_pf_emp_con() {
return emp_pf_emp_con;
}
public void setEmp_pf_emp_con(Integer emp_pf_emp_con) {
this.emp_pf_emp_con = emp_pf_emp_con;
}
public Integer getEmp_gross() {
return emp_gross;
}
public void setEmp_gross(Integer emp_gross) {
this.emp_gross = emp_gross;
}
public Integer getEmp_pf() {
return emp_pf;
}
public void setEmp_pf(Integer emp_pf) {
this.emp_pf = emp_pf;
}
public Integer getEmp_itax() {
return emp_itax;
}
public void setEmp_itax(Integer emp_itax) {
this.emp_itax = emp_itax;
}
public Integer getEmp_pro_tax() {
return emp_pro_tax;
}
public void setEmp_pro_tax(Integer emp_pro_tax) {
this.emp_pro_tax = emp_pro_tax;
}
public Integer getEmp_other_deduct() {
return emp_other_deduct;
}
public void setEmp_other_deduct(Integer emp_other_deduct) {
this.emp_other_deduct = emp_other_deduct;
}
public Integer getEmp_tot_deduct() {
return emp_tot_deduct;
}
public void setEmp_tot_deduct(Integer emp_tot_deduct) {
this.emp_tot_deduct = emp_tot_deduct;
}
public Integer getEmp_net_sal() {
return emp_net_sal;
}
public void setEmp_net_sal(Integer emp_net_sal) {
this.emp_net_sal = emp_net_sal;
}
public Date getDate_time() {
return date_time;
}
public void setDate_time(Date date_time) {
this.date_time = date_time;
}
public String getMonth_salary() {
return month_salary;
}
public void setMonth_salary(String month_salary) {
this.month_salary = month_salary;
}
public String getCreate_user() {
return create_user;
}
public void setCreate_user(String create_user) {
this.create_user = create_user;
}
public String getModify_user() {
return modify_user;
}
public void setModify_user(String modify_user) {
this.modify_user = modify_user;
}



}

Provide Hibernate Integration Through A class without using a plugin class?
public class HibernateSessionFactory {

/**
* Location of hibernate.cfg.xml file.
* Location should be on the classpath as Hibernate uses
* #resourceAsStream style lookup for its configuration file.
* The default classpath location of the hibernate config file is
* in the default package. Use #setConfigFile() to update
* the location of the configuration file for the current session.
*/
private static String CONFIG_FILE_LOCATION = "com/centris/atr/dao/sessionfactory/hibernate.cfg.xml";

private static final ThreadLocal threadLocal = new ThreadLocal();
private static Configuration configuration = new Configuration();
private static org.hibernate.SessionFactory sessionFactory;
private static String configFile = CONFIG_FILE_LOCATION;

static {
try {
configuration.configure(configFile);
sessionFactory = configuration.buildSessionFactory();
} catch (Exception e) {
System.err
.println("%%%% Error Creating SessionFactory %%%%");
e.printStackTrace();
}
}
private HibernateSessionFactory() {
}

/**
* Returns the ThreadLocal Session instance. Lazy initialize
* the SessionFactory if needed.
*
* @return Session
* @throws HibernateException
*/
public static Session getSession() throws HibernateException {
Session session = (Session) threadLocal.get();

if (session == null || !session.isOpen()) {
if (sessionFactory == null) {
rebuildSessionFactory();
}
session = (sessionFactory != null) ? sessionFactory.openSession()
: null;
threadLocal.set(session);
}

return session;
}

/**
* Rebuild hibernate session factory
*
*/
public static void rebuildSessionFactory() {
try {
configuration.configure(configFile);
sessionFactory = configuration.buildSessionFactory();
} catch (Exception e) {
System.err
.println("%%%% Error Creating SessionFactory %%%%");
e.printStackTrace();
}
}

/**
* Close the single hibernate session instance.
*
* @throws HibernateException
*/
public static void closeSession() throws HibernateException {
Session session = (Session) threadLocal.get();
threadLocal.set(null);

if (session != null) {
session.close();
}
}

/**
* return session factory
*
*/
public static org.hibernate.SessionFactory getSessionFactory() {
return sessionFactory;
}

/**
* return session factory
*
* session factory will be rebuilded in the next call
*/
public static void setConfigFile(String configFile) {
HibernateSessionFactory.configFile = configFile;
sessionFactory = null;
}

/**
* return hibernate configuration
*
*/
public static Configuration getConfiguration() {
return configuration;
}

}

Create Configuration .xml file?




com.mysql.jdbc.Driver
jdbc:mysql://192.168.1.101:3306/test
test
test
10
org.hibernate.dialect.HSQLDialect
true
update









Create Hbm.xml file?
which can be used to provide mapping between pojoclass and respective table,property and column names.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
    <class name="com.centris.atr.dao.pojos.AtrEmployeeInfo" table="atr_employee_info_audit" >
        <id name="emp_info_audit_key" type="java.lang.Integer">
            <column name="emp_info_audit_key" length="8" />
            <generator class="native" />
        </id>
        <property name="empcode" type="java.lang.String">
            <column name="empcode" length="25" />
        </property>
        <property name="empname" type="java.lang.String">
            <column name="empname" length="15" />
        </property>
        <property name="emp_designation" type="java.lang.String">
            <column name="emp_designation" length="10" />
        </property>
        <property name="emp_department" type="java.lang.String">
            <column name="emp_department" length="40" />
        </property>
        <property name="emp_bank_acc_no" type="java.lang.String">
            <column name="emp_bank_acc_no" length="40" />
        </property>
        <property name="emp_email" type="java.lang.String">
            <column name="emp_email" length="10" />
        </property>
        <property name="emp_no_ofdays_worked" type="java.lang.Integer">
            <column name="emp_no_ofdays_worked" length="40" />
        </property>
        <property name="emp_basic" type="java.lang.Integer">
            <column name="emp_basic" length="25" />
        </property>
        <property name="emp_hra" type="java.lang.Integer">
            <column name="emp_hra" />
        </property>
        <property name="emp_conveyance" type="java.lang.Integer">
            <column name="emp_conveyance" length="15" />
        </property>
        <property name="emp_onsite_allowence" type="java.lang.Integer">
            <column name="emp_onsite_allowence" length="1" />
        </property>
        <property name="emp_medical" type="java.lang.Integer">
            <column name="emp_medical" length="30" />
        </property>
        <property name="emp_pf_emp_con" type="java.lang.Integer">
            <column name="emp_pf_emp_con" length="10" />
        </property>
        <property name="emp_gross" type="java.lang.Integer">
            <column name="emp_gross" length="10" />
        </property>
        <property name="emp_pf" type="java.lang.Integer">
            <column name="emp_pf" length="5" />
        </property>
        <property name="emp_itax" type="java.lang.Integer">
            <column name="emp_itax" length="10" />
        </property>
        <property name="emp_pro_tax" type="java.lang.Integer">
            <column name="emp_pro_tax" length="10" />
        </property>
        <property name="emp_other_deduct" type="java.lang.Integer">
            <column name="emp_other_deduct" />
        </property>
        <property name="emp_tot_deduct" type="java.lang.Integer">
            <column name="emp_tot_deduct" length="4" />
        </property>
        <property name="emp_net_sal" type="java.lang.Integer">
            <column name="emp_net_sal" length="15" />
        </property>
        <property name="date_time" type="java.sql.Date">
            <column name="date_time" length="15" />
        </property>
        <property name="month_salary" type="java.lang.String">
            <column name="month_salary" length="100" />
        </property>
        <property name="create_user" type="java.lang.String">
            <column name="create_user" length="35" />
        </property>
        <property name="modify_user" type="java.lang.String">
            <column name="modify_user" length="35" />
        </property>
     
    </class>
</hibernate-mapping&gt


Create A pojo class ?
Pojo class is same as dto class which had wrritten.

.To Display data in a Jsp page? 

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
    <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
        <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
        <%@taglib uri="http://displaytag.sf.net" prefix="display" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body background="blue">
<jsp:include page="header.jsp"></jsp:include>
<logic:present name="searchresults" >

<table border="1" bgcolor="cyan" cellpadding="4" cellspacing="2">
<tr>
<td>emp_info_audit_key</td>
<td>empcode</td>
<td>empname</td>
<td>emp_designation</td>
<td>emp_department</td>
<td>emp_bank_acc_no</td>
<td>emp_email</td>
<td>emp_no_ofdays_worked</td>
<td>emp_basic</td>
<td>emp_hra</td>
<td>emp_conveyance</td>
<td>emp_onsite_allowence</td>
<td>emp_medical</td>
<td>emp_pf_emp_con</td>
<td>emp_gross</td>
<td>emp_pf</td>
<td>emp_itax</td>
<td>emp_pro_tax</td>
<td>emp_other_deduct</td>
<td>emp_tot_deduct</td>
<td>emp_net_sal</td>
<td>date_time</td>
<td>month_salary</td>
<td>create_user</td>
<td>modify_user</td>
</tr>


<logic:iterate id="reportSearch" name="searchresults" scope="session">
<tr>
<td><bean:write property="emp_info_audit_key" name="reportSearch"/></td>
<td><bean:write property="empcode" name="reportSearch"/></td>
<td><bean:write property="empname" name="reportSearch"/></td>
<td><bean:write property="emp_designation" name="reportSearch"/></td>
<td><bean:write property="emp_department" name="reportSearch"/></td>
<td><bean:write property="emp_bank_acc_no" name="reportSearch"/></td>
<td><bean:write property="emp_email" name="reportSearch"/></td>
<td><bean:write property="emp_no_ofdays_worked" name="reportSearch"/></td>
<td><bean:write property="emp_basic" name="reportSearch"/></td>
<td><bean:write property="emp_hra" name="reportSearch"/></td>
<td><bean:write property="emp_conveyance" name="reportSearch"/></td>
<td><bean:write property="emp_onsite_allowence" name="reportSearch"/></td>
<td><bean:write property="emp_medical" name="reportSearch"/></td>
<td><bean:write property="emp_pf_emp_con" name="reportSearch"/></td>
<td><bean:write property="emp_gross" name="reportSearch"/></td>
<td><bean:write property="emp_pf" name="reportSearch"/></td>
<td><bean:write property="emp_itax" name="reportSearch"/></td>
<td><bean:write property="emp_pro_tax" name="reportSearch"/></td>
<td><bean:write property="emp_other_deduct" name="reportSearch"/></td>
<td><bean:write property="emp_tot_deduct" name="reportSearch"/></td>
<td><bean:write property="emp_net_sal" name="reportSearch"/></td>
<td><bean:write property="date_time" name="reportSearch"/></td>
<td><bean:write property="month_salary" name="reportSearch"/></td>
<td><bean:write property="create_user" name="reportSearch"/></td>
<td><bean:write property="modify_user" name="reportSearch"/></td>

</tr>
</logic:iterate>
</table>
</logic:present>
<br><br><br><br><br><br><br>



<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>



<jsp:include page="footer.jsp"></jsp:include>
</body>
</html>

This is the way to search data from database........

Read more...

FaceBook Login

HTML/JAVASCRIPT

HTML/JAVASCRIPT

HTML/JAVASCRIPT

HTML/JAVASCRIPT

Total Pageviews

STATCOUNTER

  © Blogger template Simple n' Sweet by Ourblogtemplates.com 2009

Back to TOP