shraddha srivastava
How to connect to dao n bean classes with jsp
0 Answer(s)      3 years and 6 months ago
Posted in : JSP-Servlet

I have made this edao pkg

package edao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;

import ebean.Add_Village;

public class AddVillageInfo extends EConnect {
Connection con;

    public boolean save_add(Add_Village ad)
    {
        try{
            con=getConnection();
            Statement st=con.createStatement();
            ResultSet rs1=st.executeQuery("select Id from AddVillageDetails");
            String temp="1";
            while(rs1.next())
            {
                temp=rs1.getString(1);
            }

            temp=String.valueOf(Integer.parseInt(temp)+1);
            PreparedStatement stmt=con.prepareStatement("insert into AddVillageDetails values(?,?,?,?,?,?,?,?,?)");
            System.out.println("start");
            stmt.setString(1,temp);
            stmt.setString(2,ad.getState());
            stmt.setString(3,ad.getDistrict());
            stmt.setString(4,ad.getTehsil());
            stmt.setString(5,ad.getVillageName());
            stmt.setString(6,ad.getSurpanchName());
            stmt.setString(7,ad.getNoOfHouseHolds());
            stmt.setString(8,ad.getNoOfLandSellers());
            stmt.setString(9,ad.getTotalVillageArea());
            System.out.println("Bean set");

            stmt.executeUpdate();
            return true;
        }
        catch(Exception e)
        {
            e.printStackTrace();
            System.out.println(e);
            return false;
        }
    }

}


**then i have this ebean pkg**

package ebean;

public class Add_Village {
    String Id,State,District,Tehsil,VillageName,SurpanchName,NoOfHouseHolds,NoOfLandSellers,TotalVillageArea;

    public String getId() 
    {
        return Id;
    }

    public void setId(String id)
    {
        Id = id;
    }

    public String getState()
    {
        return State;
    }

    public void setState(String state) 
    {
        State = state;
    }

    public String getDistrict() 
    {
        return District;
    }

    public void setDistrict(String district) 
    {
        District = district;
    }

    public String getTehsil() 
    {
        return Tehsil;
    }

    public void setTehsil(String tehsil) 
    {
        Tehsil = tehsil;
    }

    public String getVillageName() 
    {
        return VillageName;
    }

    public void setVillageName(String villagename) 
    {
        VillageName = villagename;
    }

    public String getSurpanchName() 
    {
        return SurpanchName;
    }

    public void setSurpanchName(String surpanchname) 
    {
        SurpanchName = surpanchname;
    }

    public String getNoOfHouseHolds() 
    {
        return NoOfHouseHolds;
    }

    public void setNoOfHouseHolds(String noofhouseholds) 
    {
        NoOfHouseHolds = noofhouseholds;
    }


    public String getNoOfLandSellers() 
    {
        return NoOfLandSellers;
    }

    public void setNoOfLandSellers(String nooflandsellers) 
    {
        NoOfLandSellers = nooflandsellers;
    }

    public String getTotalVillageArea() 
    {
        return TotalVillageArea;
    }

    public void setTotalVillageArea(String totalvillagearea) 
    {
        TotalVillageArea = totalvillagearea;
    }

}



**how to connect with this edao and ebean pkg with my jsp page**

<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%  String state=request.getParameter("state");
    String district=request.getParameter("district");
    String tehsil=request.getParameter("tehsil");
    String villagename=request.getParameter("villagename");
    String surpanchname=request.getParameter("surpanchname");
    String noofhouseholds=request.getParameter("noofhouseholds");
    String nooflandsellers=request.getParameter("nooflandsellers");
    String totalvillagearea=request.getParameter("totalvillagearea");
%>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>AddVillagejsp</title>
</head>

<body bottommargin="2" leftmargin="10" rightmargin="10" topmargin="1">

<table  align="center"  cellSpacing=0  cellPadding=0  width="60%" border=0>
    <tbody>
        <tr>
                <td bgColor="#2a5865" colSpan=1>
                    <IMG height=4 src="images/zero.gif" width=1>
                </td>
        </td>
</tbody>
</table>

<table align="center" width="60%" height="100" >
    <tr>

        <td width="40%" height="100">
                <p align="right" style="margin-top: 0; margin-bottom: 0"> 
                <img src="images/avantha1.jpg" width="520" height="100"></p>
        </td>


            <td width="20%" height="100">
                <p align="right" style="margin-top: 0; margin-bottom: 0"> 
              <img src="images/logo[2].gif" width="200" height="100"></p>
      </td>
  </tr>
</table>

<body style="margin-left: 10pt; margin-right: 10pt; margin-bottom: 5pt"  >

<TD background="images/dot.gif"><IMG height=4 src="images/zero.gif" width=25></TD>
</TR></TBODY></TABLE>
<br>
<table width="60%"  height="40" border="0" cellpadding="6" cellspacing="0" align="center">
    <tbody>
    <tr>
        <td valign="top" align="center" bgcolor="#2a5865"><font class="blackboldtxt"><font color="#ffffff" size=5><b>Add Village Details</b></font></font></td></tr>
        </td>
    </tr> 


<form name="VillageDetailsForm" action="simple.jsp" method="post" onSubmit="return adsvalidate();">
<table width="50%" height="400" bgcolor="#ecf7fb" border="0" cellpadding="0" cellspacing="0" align="center">
<br>
<tbody><tr><td colspan="2" align="center"><font class="textsmallbluenormal"><font color="#333333">All fields marked with <font color="#d36000">*</font> are mandatory.</font></font></td></tr>


<tr>
    <td style="padding-left: 15px; padding-top: 10px;" valign="middle" width="200"><font class="blackboldtxt"><font color="#003e7b">State :</font></font> <font class="smalltext"><font color="#d36000">*</font></font></td>
    <td style="padding-top: 10px;" valign="top">
    <select style="width: 175px; font-family: arial,Verdana,sans-serif; font-size: 8pt;" class="textfiled" name="State" onChange="fillSelectFromArray(this.form.City, ((this.selectedIndex == -1) ? null : residingcity[this.selectedIndex-1]));getLocality();">
    <option value="0" selected="selected"> ---------- Select State ---------- </option>
    <option value="1">Chhattisgarh</option>
    <option value="2">Madhya Pradesh</option>
    </select>
    </td>
</tr>


<tr>
<td style="padding-left: 15px; padding-top: 10px;" valign="middle">
<font class="blackboldtxt"><font color="#003e7b">District :</font> <font class="smalltext"><font color="#d36000">*</font></font></font>
</td>
<td style="padding-top: 10px;" valign="top">
<input class="addtextfiled" size="25" name="District" value="">
</td>
</tr>


<tr>
<td style="padding-left: 15px; padding-top: 10px;" valign="middle">
<font class="blackboldtxt"><font color="#003e7b">Tehsil/Taluka/Block :</font> <font class="smalltext"><font color="#d36000">*</font></font></font>
</td>
<td style="padding-top: 10px;" valign="top">
<input class="addtextfiled" size="25" name="tehsil" value="">
</td>
</tr>

<tr>
<td style="padding-left: 15px; padding-top: 10px;" valign="middle">
<font class="blackboldtxt"><font color="#003e7b">Village :</font> <font class="smalltext"><font color="#d36000">*</font></font></font>
</td>
<td style="padding-top: 10px;" valign="top">
<input class="addtextfiled" size="25" name="VillageName" value="">
</td>
</tr>


<tr>
<td style="padding-left: 15px; padding-top: 10px;" valign="middle">
<font class="blackboldtxt"><font color="#003e7b">Surpanch Name :</font></font> <font class="smalltext"><font color="#d36000">*</font></font></td>
<td style="padding-top: 10px;" valign="top">
<input class="addtextfiled" size="25" name="SurpanchName" value="">
</td>
</tr>


<tr>
<td style="padding-left: 15px; padding-top: 10px;" valign="middle">
<font class="blackboldtxt"><font color="#003e7b">No. Of HouseHolds :</font></font> <font class="smalltext"><font color="#d36000">*</font></font></td>
<td style="padding-top: 10px;" valign="top">
<input class="addtextfiled" size="15" name="NumberOfHouseHolds" value="">
</td>
</tr>



<tr>
<td style="padding-left: 15px; padding-top: 10px;" valign="middle">
<font class="blackboldtxt"><font color="#003e7b">No. Of Land Sellers :</font></font> <font class="smalltext"><font color="#d36000">*</font></font></td>
<td style="padding-top: 10px;" valign="top">
<input class="addtextfiled" size="15" name="NumberOfLandLosers" value="">
</td>
</tr>



<tr>
<td style="padding-left: 15px; padding-top: 10px;" valign="middle">
<font class="blackboldtxt"><font color="#003e7b">Total Village Area :</font></font> <font class="smalltext"><font color="#d36000">*</font></font></td>
<td style="padding-top: 10px;" valign="top">
<input class="addtextfiled" size="15" name="TotalVillageArea" value="">
</td>
</tr>


<tr>
                      <td colspan="2" valign="top" align="middle"><br>
                          <input name="file_name" value="newuser" type="hidden">
                          <input name="Country" value="" type="hidden">
                          <input name="reset" src="login.php_files/submit-button.gif" value="Clear" type="reset" width="62" border="0" height="19">
                                          
                          <input name="post" src="login.php_files/submit-button.gif" value="Submit" type="submit" width="62" border="0"height="19" onClick='return check(frm)'>
                                          
                          <input name="reset" src="login.php_files/submit-button.gif" value="Back" type="reset" width="62" border="0" height="19" onClick="history.go(-1)">              
                     </td>


</tr>

</tbody>
</table>
</form>
</td>
</tr>
</tbody>
</table>
<!-- End of New Village Registration -->
<jsp:useBean id="adinfo" class="ebean.Add_Village"></jsp:useBean>
    <% AddVillageInfo ad=new AddVillageInfo();

    ad.setState("state");
    ad.setDistrict("district");
    ad.setTehsil("tehsil");
    ad.setVillageName("villagename");
    ad.setSurpanchName("surpanchname");
    ad.setNoOfHouseHolds("noofhouseholds");
    ad.setNoOfLandsellers("nooflandsellers");
    ad.setTotalVillageArea("totalvillagearea"));    
    boolean b=adinfo.save_add(ad);
    %>
</body>
</html>

it gives an error that it doesnt import my pkg

Advertisement
View Answers









Related Tutorials/Questions & Answers:
How to connect to dao n bean classes with jsp
How to connect to dao n bean classes with jsp  I have made this edao... = totalvillagearea; } } **how to connect with this edao and ebean pkg with my jsp...()); System.out.println("Bean set"); stmt.executeUpdate
DAO Classes
DAO Classes  login page code for Dao classes
Advertisements
How to connect mysql with jsp
How to connect mysql with jsp  how to connect jsp with mysql while using apache tomcat
How to display data in jsp from dao using java beans?
How to display data in jsp from dao using java beans?  Hi I need to display data in jsp pulling from dao using java beans, Please can anyone give me the sample application with above topics. Any help would be highly appreciated
how to connect jsp to mysql - Java Beginners
how to connect jsp to mysql  I m new in Mysql and JSP i m ceating.java file using bean file for connectivity but i m not able to connect jsp... me hw to conncet jsp with mysql this is connection file package connect
how to connect to MS access database in JSP?
how to connect to MS access database in JSP?  how to connect to MS access database in JSP? Any seetings/drivers need to be set or installed before... DSN will get created. 6) Restart your server and run your jsp code. Here is your
How to connect
How to connect  how to connect to a remote host using jsp? We need to update files to the database of the application on the local machine from the updated database on our webpage
how to Use jsp:setProperty to set one bean in other bean while to be set bean is of type java.util.List<beantype>
how to Use jsp:setProperty to set one bean in other bean while to be set bean...; private int numOfPages; // Getters and Setters I have a single jsp (a.jsp) containing input fields for all the 3 classes, and action of that jsp
how to connect jsp with sql database by netbeans in a login page?
how to connect jsp with sql database by netbeans in a login page?  how to connect jsp with sql database by netbeans in a login page
how to connect jsp with sql database by netbeans in a login page?
how to connect jsp with sql database by netbeans in a login page?  how to connect jsp with sql database by netbeans in a login page
how to connect jsp with sql database by netbeans in a login page?
how to connect jsp with sql database by netbeans in a login page?  how to connect jsp with sql database by netbeans in a login page
how to create dao
how to create dao   code1: package com.dao; import java.sql.*; import com.beans.*; public class DbAccess { public void createStudent(SampleBean sampleBean) throws SQLException { Connection con=null; try
How to get the output of JSP program using Bean
How to get the output of JSP program using Bean  Hi Kindly go... visit the following link: http://www.roseindia.net/jsp/using-bean-counter.shtml...; <jsp:useBean id="counter" scope="session" class="CounterBean" /> <
how to create bean using jsp and servlet
how to create bean using jsp and servlet  public class SampleBean... the following links: http://www.roseindia.net/jsp/usingbeansinjsp.shtml http://www.roseindia.net/jsp/loginbean.shtml
How to get the output of jsp program using Bean
How to get the output of jsp program using Bean  Hello my Roseindia...; Next i created JSP program for the above one by using Bean and i opened..." %> <HTML> <HEAD> <TITLE>Use Bean Counter Example <
how to connect the database using hibernet through servlet/jsp through form
how to connect the database using hibernet through servlet/jsp through form  plz give me the reply   Hi Friend, Please visit the following link: http://www.roseindia.net/jsf/myfacesspring/loginRegistration.shtml Hope
Connect JSP with mysql
; This query creates database 'usermaster' in Mysql. Connect JSP with mysql : Now in the following jsp code, you will see how to connect... Connect JSP with mysql   
connect to the database from JSP
connect to the database from JSP  How do you connect to the database from JSP?   A Connection to a database can be established from a jsp page by writing the code to establish a connection using a jsp scriptlets
RMI n JSP - RMI
RMI n JSP  Hi Friends, First of all let me appreciate ur promptness in delivering answers. Is it possible to make communication between RMI and JSP page ? Thanks
RMI n JSP - RMI
RMI n JSP  Hi Friends, First of all let me appreciate ur promptness in delivering answers. Is it possible to make communication between RMI and JSP page ? Thanks
Connect from database using JSP Bean file
Connect from database using JSP Bean file...; is doing the loading of bean file from the classes. <jsp:useBean id....   <jsp:useBean id=?bean name? class=?bean class?  scope
how to login form through spring dao module
how to login form through spring dao module  here i want to chek user details in database through form by using spring dao module.please give me some reference example to me
how to connect webcam in html
how to connect webcam in html  how to connect webcam in html.emphasized text
How to connect with database
How to connect with database  jdbc connection
dao
(); } return conn; } } //bean: package
drag n drop - JSP-Servlet
drag n drop  I want to implement drag n drop functionality for simple HTML/JSP without using applet,flash or any heavy components.using browse button... using drag and drop mode.when user drag n drop file then display the complete path
how to find the eigenvalue and eigenvector of n*n matrix in java
how to find the eigenvalue and eigenvector of n*n matrix in java  I m the new beginner in java and want to find eigenvalue and eigenvector of n*n matrix.where n is vary from n=4,5,6...... pls help me that would be appreciable
how to create a slider on jsp page n slider has values from 0-4
how to create a slider on jsp page n slider has values from 0-4  i want to create a slider on jsp page and slider has values from 0-4   Using the jquery, you can create a slider in jsp. <html> <head> <
Connect JSP with mysql
you how to connect to MySQL database from your JSP code. First, you need to create database and then write jsp code to connect jsp to database. 1. Create... Connect JSP with mysql   
how to connect jdbc
how to connect jdbc  package com.tcs.ilp.Try.Controller; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import
bean - JSP-Interview Questions
bean  what is use bean in jsp?  Hi Friend, Please visit the following links: http://www.roseindia.net/jsp/using-bean-counter.shtml http://www.roseindia.net/jsp/java-bean-example-jsp.shtml Hope