Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Struts Struts2 and Hibernate Fetch Data Base Value
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Rakesh K Prajapat
Struts2 and Hibernate Fetch Data Base Value
1 Answer(s)      a year and 3 months ago
Posted in : Struts


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");

Advertisement
View Answers

September 2, 2013 at 4:27 PM




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
insert excel value in to oracle data base
insert excel value in to oracle data base  Hi All I am using this code for saving excel value to oracle database table. code is working properly but in table i am geting some diffrent type value like... o
Data fetch from multiple SQL tables - Hibernate
Data fetch from multiple SQL tables   I am in the process of writing my first hibernate application. I have a sql query that fetches data from multiple tables using left and right outer joins. I need to convert this JDBC data
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
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
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
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
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
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
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
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
Integrate Hibernate to struts2.
Integrate Hibernate to struts2.  How to Integrate Struts Hibernate
Data base Connectivity
Data base Connectivity  How to configure JDBC connection for Oracle data base.In configuring it is asking select Data server name and TNS.I typed Oracle for Data Server Name and IN TNS what to type? I pulled the list for TNS
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 insertion and fetch 1
data insertion and fetch 1  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ <...; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ insert int data base @@@@@@@@@ import...;Gender</b><input type="radio" name="sex" value="male">Male
JSP data base validation
JSP data base validation  please explain how to validate form input string with database n also how its notify that entered data exists already...;td><input type="submit" value="submit"/></td> </tr> <
Data base related question
Data base related question  sir my table has only one element(that is pno),i am using ms-access as backend. i put only one element i want to retrieve that element .how can i retrieve that element,using jdbc technology. please
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
how to fetch data from servlet ????
how to fetch data from servlet ????  how to fetch data from servlet
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
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
Data base - JDBC
Data base  I want to do this Inserting a record with Object type column using PreparedStatement but wht should b the column datatype this is te..."); con.close(); }//main }//class For this should i create a user defined data type
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
struts2+hibernate - Struts
struts2+hibernate  How to use hibernate 3 with struts 2 application? kindly reply with example
please send me the banking data base in swings
please send me the banking data base in swings  sir, please send me how to create the banking data base program in swings
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
 

 

 

DMCA.com