Struts2 and Hibernate Fetch Data Base Value

Struts2 and Hibernate Fetch Data Base Value

Hello Sir,

I am facing the problem while fetching the database value on jsp page while using struts2.0 and hibernate3.0 and MySql try to help me resolve this problem and try to tell me what should i do for fetch the database value and shown on jsp page.

AdminProvideLeave Pojo Class

package mypack;

> public class AdminProvideLeave {
> 
> private static long serialVersionUID =
> 1L;
> 
> private int rpl, rcl, rsl, rel,
> serial_no, rtotal_leave;
> 
> public AdminProvideLeave() { super();
> // TODO Auto-generated constructor
> stub }
> 
> public AdminProvideLeave(int rpl, int
> rcl, int rsl, int rel, int
> rtotal_leave, int serial_no) {
> super(); this.rpl = rpl; this.rcl =
> rcl; this.rsl = rsl; this.rel = rel;
> this.serial_no= serial_no;
> this.rtotal_leave= rtotal_leave; }
> 
> public static long
> getSerialVersionUID() { return
> serialVersionUID; }
> 
> public static void
> setSerialVersionUID(long
> serialVersionUID) {
> AdminProvideLeave.serialVersionUID =
> serialVersionUID; }
> 
> public int getRpl() { return rpl; }
> 
> public void setRpl(int rpl) { this.rpl
> = rpl; }
> 
> public int getRcl() { return rcl; }
> 
> public void setRcl(int rcl) { this.rcl
> = rcl; }
> 
> public int getRsl() { return rsl; }
> 
> public void setRsl(int rsl) { this.rsl
> = rsl; }
> 
> public int getRel() { return rel; }
> 
> public void setRel(int rel) { this.rel
> = rel; } public int getSerial_no() { return serial_no; }
> 
> public void setSerial_no(int serialNo)
> { serial_no = serialNo; }
> 
> public int getRtotal_leave() { return
> rtotal_leave; }
> 
> public void setRtotal_leave(int
> rtotalLeave) { rtotal_leave =
> rtotalLeave; }
> 
> 
> }
> 
//  AdminProvidLeaveAction Class package
> mypack;
> 
> import java.util.*; import
> java.util.List;
> 
> import
> com.opensymphony.xwork2.ActionSupport;
> 
> public class AdminProvideLeaveAction
> extends ActionSupport { private static
> final long serialVersionUID= 1L;
> public AdminProvideLeave apl; public
> List<AdminProvideLeave>apllist; Dao
> dao= new Dao(); public String
> execute() {
> 
> dao.save(apl); return "success"; }
> 
> public String fetch() {
> 
> apllist=dao.fetch1(); return
> "success"; }
> 
> public AdminProvideLeave getApl() {
> return apl; }
> 
> public void setApl(AdminProvideLeave
> apl) { this.apl = apl; } public
> List<AdminProvideLeave> getApllist() {
> return apllist; }
> 
> public void
> setApllist(List<AdminProvideLeave>
> apllist) { this.apllist = apllist; }
> 
> public static long
> getSerialversionuid() { return
> serialVersionUID; }
> 
> }

// Dao Class import java.util.ArrayList;
> import java.util.List; import
> org.hibernate.HibernateException;
> import org.hibernate.Query; import
> org.hibernate.Session; import
> org.hibernate.SessionFactory; import
> org.hibernate.Transaction; import
> org.hibernate.cfg.Configuration;
> 
> public class Dao {
> 
> public void save(Object O) {
> Configuration cfg = new
> Configuration().configure();
> SessionFactory f =
> cfg.buildSessionFactory(); Session
> session = f.openSession(); Transaction
> t = session.beginTransaction();
> session.save(O); t.commit();
> session.close(); }
> 
> @SuppressWarnings("unchecked") public
> List<AdminProvideLeave>fetch1()// for
> fetch the value from database on jsp
> page {
> 
> Configuration cfg = new
> Configuration().configure();
> SessionFactory f =
> cfg.buildSessionFactory(); Session
> session = f.openSession(); Transaction
> t = session.beginTransaction();
> List<AdminProvideLeave>apllist = new
> ArrayList<AdminProvideLeave>(); try {
> Query q = session.createQuery("from
> AdminProvideLeave"); apllist =
> q.list(); } catch (HibernateException
> he) { System.out.println(he); }
> t.commit(); session.close(); return
> apllist; }
> 
> @SuppressWarnings("unchecked")// For
> insert the value in database public
> List<AdminProvideLeave> apllist() {
> Configuration cfg = new
> Configuration().configure();
> SessionFactory f =
> cfg.buildSessionFactory(); Session
> session = f.openSession();
>   Transaction t =
> session.beginTransaction();
>   List<AdminLeavePojo> adlp = null;   
>   try {       Query q =
> session.createQuery("from
> AdminProvideLeave");      adlp =
> q.list();
>           } catch (HibernateException e) {        System.out.println(e);  }
>           t.commit();     session.close();
> 
>   return adlp; } }
// ----------------
> 
> Struts.xml  <action
> name="adminaddleave"
> class="mypack.AdminProvideLeaveAction"
> method="execute"> <result
> name="success">welcome2.jsp</result>
> <result name="success"
type="redirect">fetch</result>
</action> 
<action name="fetch" class="mypack.AdminProvideLeaveAction"
method="fetch"> <result name="success">viewleave.jsp</result>

// ViewLeave.jsp align="center">

<s:form theme="simple" method="post" name="rempleave">
<s:label>Employee Remaining Leave:</s:label>
<table border="" align="center" style="margin-top: 28px">
<s:iterator value ="apllist" var="empleave">
<tr>
<td>
<s:property value="rcl"/>
</td>
</tr>
</s:iterator>
<!--
<tr style="height: 40px">
<td style="width: 200px; text-align: center">
<b>Leave Type</b>
</td>
<td style="width: 100px; text-align: center">
<b>Leave</b>
</td>
</tr>
-->
<tr style="height: 40px">
<td style="width: 200px; text-align: center">
RPL
</td>
<td id="pl" style="text-align: center" name="rpl">
</td>
</tr>
<tr style="height: 40px">
<td style="width: 200px; text-align: center">
RCL
</td>
<td id="cl" style="text-align: center" name="rcl">
</td>
</tr>
<tr style="height: 40px">
<td style="width: 200px; text-align: center">
RSL
</td>
<td id="sl" style="text-align: center" name="rsl">                              
</td>
</tr>
<tr style="height: 40px">
<td style="width: 200px; text-align: center">
REL
</td>
<td id="el" style="text-align: center" name="rel">

</td>
</tr>
<tr style="height: 40px">
<td style="width: 200px; text-align: center">
RLWP
</td>
<td id="lwp" style="text-align: center" name= "rlwp">       
</td>
</tr>
<tr style="height: 40px">
<td style="width: 200px; text-align: center"> <input type="button" value="R Leave" onclick=Total();
</td>
<td id="total" style="text-align: center">
</td>
</table>
</s:form>`print("code sample");
View Answers

September 2, 2013 at 4:27 PM

Ads









Related Tutorials/Questions & Answers:
Struts2 and Hibernate Fetch Data Base Value
Struts2 and Hibernate Fetch Data Base Value  Hello Sir, I am... me what should i do for fetch the database value and shown on jsp page...") public > List<AdminProvideLeave>fetch1()// for > fetch the value from
Struts2 and Hibernate Fetch Data Base Value
Struts2 and Hibernate Fetch Data Base Value  Hello Sir, I am... me what should i do for fetch the database value and shown on jsp page...") public > List<AdminProvideLeave>fetch1()// for > fetch the value from
Advertisements
Struts2 and Hibernate
Struts2 and Hibernate  how to fetch database value from one page to another page in struts2 and hibernate
Struts2 and Hibernate
Struts2 and Hibernate  Sir/ madam, Can we use iterator tag in struts for fetch the database value and shown on form. if yes then how
Struts2 and Hibernate
Struts2 and Hibernate   I have a simple application in Struts2 and Hibernate which have simple form for entering contact information and after... it data saved and comes to the JSP. But initially No data shows. Please help me as i
Struts2 and Hibernate
Struts2 and Hibernate   I have a simple application in Struts2 and Hibernate which have simple form for entering contact information and after... database on to the JSP page when it initially loads. After Submitting it data
Struts2 and Hibernate
Struts2 and Hibernate  Hello Sir, I am trying to fetch database value from one page to another page. Means i am submiting the form value in database but i want to display that submit database value in another page while
how read excel data into database using struts2 with hibernate
how read excel data into database using struts2 with hibernate   hi friends, i am venkat i am started learning struts 2, please help me how to read excel data into database using struts2 with hibernate, please show me
how to fetch data fron facebbok using spring batch and hibernate ?
how to fetch data fron facebbok using spring batch and hibernate ?  how to fetch data from facebbok using spring batch and hibernate ? Means i have... details of data to local database and fetch all details if data
Integrate Hibernate to struts2.
Integrate Hibernate to struts2.  How to Integrate Struts Hibernate
STRUTS2 Dynamic data is not updated
STRUTS2 Dynamic data is not updated  Hi All, I am new in struts and try to make an application in struts2. Need help on dynamic data content. In application i am tried to fetch data and save in variable and use set & get
STRUTS2 Dynamic data is not updated
STRUTS2 Dynamic data is not updated  Hi All, I am new in struts and try to make an application in struts2. Need help on dynamic data content. In application i am tried to fetch data and save in variable and use set & get
Struts2 Spring Hibernate integration
Struts2 Spring Hibernate integration  How to integrate Struts2 Spring2.5 and Hibernate3 in a web application project?Could anyone give some example
Struts2 And Hibernate Configuration
Struts2 And Hibernate Configuration  Sir, I am new to struts2, I am trying to write a program using struts2 and hibernate. I want to know how.... Bachan Sahoo   Struts Hibernate Integration
SQL fetch value
SQL fetch value  how to get ( 15 march 2011) and (15/03/2011) output using SQL   Use the following queries to get the data from database in the given format. For (15 march 2011) format: SELECT DATE_FORMAT(dob, '%d %M
Hibernate Criteria Fetch Size Example
Hibernate Criteria Fetch Size Example  I want example of Hibernate Criteria Fetch Size. Share me the best example program and tutorial of Hibernate Criteria Fetch Size. Thanks   Best Example of Hibernate Criteria Fetch
Hibernate criteria example using struts2
Hibernate criteria example using struts2 This hibernate criteria example using struts2 is used for defining the basics of criteria. The hibernate criteria... create query without HQL. In this hibernate criteria example using struts2, we
how to get time picker value in javascript of struts2
how to get time picker value in javascript of struts2  I am not able to get value of time picker in java script . my code is jsp java script var totime=dojo.widget.byId("totime").getValue(); how to get value please help me
fetch data from database in javascript
fetch data from database in javascript   How to fetch data from database in JavaScript when it is a leap year
how to fetch data from servlet ????
how to fetch data from servlet ????  how to fetch data from servlet
data insertion and fetch 1
data insertion and fetch 1  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ <...; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ insert int data base @@@@@@@@@ import...;Gender</b><input type="radio" name="sex" value="male">Male
Online Cab Booking using Java (Struts2+Hibernate)
Online Cab Booking using Java (Struts2+Hibernate)  hi anyone send me the online cab booking(cab booking and canceling)using java+Struts2 its for my interview can u send as soon as possible.. thank u :) Surya
Access value of array using OGNL in struts2.
Access value of array using OGNL in struts2. Here, you will see how to access value of  array in struts2 using OGNL.  1-index.jsp <%@taglib... value="name.size"/><br/> <p> access data of list.<
File Upload in struts2 - Invalid field value for field
File Upload in struts2 - Invalid field value for field   Hi I am... : Invalid field value for field "upload". My webContents->Web-Inf->lib... value for field "upload". on jsp page but not in console Please guide I am stuck
how to store and retrieve image using struts2 and hibernate integration
how to store and retrieve image using struts2 and hibernate integration  how to store and retrieve image using struts2 and hibernate integration? plz help !! thanks in advance
Hibernate Criteria Fetch Size
Hibernate Criteria Fetch Size Please consider the fetchSize example of hibernate criteria API CriteriaFetchSize.java package net.roseindia.main; import... as shown below: Hibernate: select this_.roll_no as roll1_0
value is inserted into the sql table through jsp-jdbc but not getting stored into the data base,only row is increasing.
value is inserted into the sql table through jsp-jdbc but not getting stored into the data base,only row is increasing.  <html> <...="Submit" value="Submit"></td> </tr> </table>
data base
data base  how to connect coding in data base ?   The given code connects JSP page to database. You need to import the mysql connection jar file to jdk as well as to the lib of tomcat. Moreover you need to set classpath
HQL Query in execute method of Struts2
HQL Query in execute method of Struts2  I am making login page in struts2 and using hibernate . Now I wants to pull user name and password from database and match the login password given by user. But I am not able to fetch
to fetch data from ms word and storing into database
to fetch data from ms word and storing into database  i want to know how to fetch datafields from ms word and storing into database??? please answer soon .its urgent
DATA BASE
DATA BASE  Create a program to establish a connection to the PCTBC... the data using a J Table.   Here is a code that connects to MySql... main(String[] args) { Vector columnNames = new Vector(); Vector data = new Vector

Ads