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




Have Programming Question? Ask it here!
 
 
 


harish h
CRUD DAO
4 Answer(s)      2 years and 8 months ago
Posted in : Java Beginners


how to create dao for create,read,update and delete?


Advertisement
View Answers

January 1, 2012 at 5:25 PM


/*
 *ConnectionManager
 *
 *
 *Version:1.0
 *
 *Date:25-Nov-2011
 *
 */
package com.student.dao;

import java.sql.*;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

public class ConnectionManager {

    static Connection con;
    static String url;
    static final Logger logger = Logger.getLogger(ConnectionManager.class);

    public static Connection getConnection() {
        PropertyConfigurator.configure("log4j.properties");
        try {
            String url = "jdbc:oracle:thin:@172.24.137.30:1521:ora10g";
            // assuming "DataSource" is your DataSource name

            Class.forName("oracle.jdbc.OracleDriver");

            try {
                con = DriverManager.getConnection(url, "e533121", "project1");

                // assuming your SQL Server's username is "username"
                // and password is "password"

            }

            catch (SQLException ex) {
                ex.printStackTrace();
            }
        }

        catch (ClassNotFoundException e) {// "logger" prints in to a file;
            // Normally used to trace the
            // process

            logger.error(e);
        }

        return con;
    }
}



createid:
/*
 *CollegeRegistrationDao
 *
 *
 *Version:1.0
 *
 *Date:31-Nov-2011
 *
 */
package com.student.dao;

import java.sql.*;

import com.student.beans.*;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

public class CreateIdDAO {
    static Connection currentCon = null;
    static ResultSet rs = null;
    static PreparedStatement pstmt = null;
    static ResultSet rs1 = null;
    static PreparedStatement pstmt1 = null;
    static final Logger logger = Logger.getLogger(CreateIdDAO.class);

    public static StudentBean register(StudentBean bean) {
        /**
         * method to search student
         * 
         * @533026,533121
         * 
         */
        // preparing some objects for connection
        Statement stmt = null;
        PropertyConfigurator.configure("log4j.properties");
        try {
            // connect to DataBase
            // connect to DataBase
            currentCon = ConnectionManager.getConnection();
            stmt = currentCon.createStatement();
            String getMax = "select Max(std_id) from studentids";
            rs1 = stmt.executeQuery(getMax);
            rs1.next();
            int maxId = rs1.getInt(1);
            System.out.println(maxId);
            int nextId = maxId + 1;
            String stdId = "S" + Integer.toString(nextId);
            String query1 = "insert into studentids values(?)";
            pstmt1 = currentCon.prepareStatement(query1);
            pstmt1.setInt(1, nextId);
            pstmt1.executeUpdate();
            bean.setStudentId(stdId);
        } catch (Exception ex) {// "logger" prints in to a file; Normally used
            // to trace the process

logger.error("Registration failed: An Exception has occurred! "
+ ex);
}

// exception handling
finally {
if (rs != null) {
try {
rs.close();
} catch (Exception e) {
}
rs = null;
}

if (stmt != null) {
try {
stmt.close();
} catch (Exception e) {
}
stmt = null;
}

if (currentCon != null) {
try {
currentCon.close();
} catch (Exception e) {
}

currentCon = null;
}
}

return bean;


}

}

registration:

try {
            // connect to DataBase
            // connect to DataBase
            currentCon = ConnectionManager.getConnection();
            String stdId=bean.getStudentId();
            System.out.println(stdId);
            // query for inserting into the table
            String query = "insert into newstudent(std_id,std_name,maths,social,hindi,science,english) values(?,?,?,?,?,?,?)";
            pstmt = currentCon.prepareStatement(query);
            // inserting values
            pstmt.setString(1,stdId);
            pstmt.setString(2,bean.getStudentName());
            pstmt.setInt(3, bean.getMaths());
            pstmt.setInt(4, bean.getSocial());
            pstmt.setInt(5, bean.getHindi());
            pstmt.setInt(6, bean.getScience());
            pstmt.setInt(7, bean.getEnglish());
            pstmt.executeUpdate();
            bean.setValid(true);

        }

delete: try {

        String std = bean.getStudentId();
        PropertyConfigurator.configure("log4j.properties");
        String searchQuery = "delete from newstudent where std_id='"+ std + "'";
        bean.setValid(true);

        // // "logger" prints in to a file; Normally used to trace the process

        logger.info("Your employee id is " + std);

        logger.info("Query: " + searchQuery);

        }

        catch (Exception ex) {
            logger.error("Log In failed: An Exception has occurred! " + ex);
        }

search:

Statement stmt = null;

        String username = bean.getStudentId();

        String searchQuery = "select * from newstudent where std_id ='"
                + username + "' ";

        // "logger" prints in to a file; Normally used to trace the process

        logger.info("Student ID is " + username);
        logger.info("Query: " + searchQuery);

        try {
            // connect to DB
            currentCon = ConnectionManager.getConnection();
            stmt = currentCon.createStatement();
            rs = stmt.executeQuery(searchQuery);
            boolean more = rs.next();

            // if user does not exist set the isValid variable to false
            if (!more) {
                logger
                        .warn("Sorry, you are not a registered user! Please sign up first");
                bean.setValid(false);
            }

            // if user exists set the isValid variable to true
            else if (more) {
                String studentId = rs.getString("std_id");
                String studentName = rs.getString("std_NAME");
                int maths = rs.getInt("maths");
                int social = rs.getInt("social");
                int hindi = rs.getInt("hindi");
                int science = rs.getInt("science");
                int english = rs.getInt("english");
                bean.setStudentId(studentId);
                bean.setStudentName(studentName);
                bean.setMaths(maths);
                bean.setSocial(social);
                bean.setHindi(hindi);
                bean.setScience(science);
                bean.setEnglish(english);
                bean.setValid(true);
                int total=maths+social+hindi+science+english;
                if(total>=450){
                    bean.setGrade("A+");
                }
                if(total>=400 && total<=449){
                    bean.setGrade("A");
                }
                if(total>=350 && total<=399){
                    bean.setGrade("B");
                }
                if(total>=300 && total<=349){
                    bean.setGrade("C");
                }
                if(total>=250 && total<=299){
                    bean.setGrade("D");
                }
                if(total>=200 && total<=249){
                    bean.setGrade("E");
                }
                if(total<200){
                    bean.setGrade("Fail");
                }
                }

        }

profile and update:
Statement stmt = null;

        String username = bean.getStudentId();
        // query to select row from College using College_Id
        String searchQuery = "select * from newstudent where std_Id='"
                + username + "' ";
        // "logger" prints in to a file; Normally used to trace the process
        logger.info("Your user name is " + username);
        logger.info("Query: " + searchQuery);

        try {
            // connect to DataBase
            currentCon = ConnectionManager.getConnection();
            stmt = currentCon.createStatement();
            rs = stmt.executeQuery(searchQuery);
            boolean more = rs.next();
            // check for rows
            if (more) {

                String studentId = rs.getString("std_id");
                String studentName = rs.getString("std_NAME");
                int maths = rs.getInt("maths");
                int social = rs.getInt("social");
                int hindi = rs.getInt("hindi");
                int science = rs.getInt("science");
                int english = rs.getInt("english");
                bean.setStudentId(studentId);
                bean.setStudentName(studentName);
                bean.setMaths(maths);
                bean.setSocial(social);
                bean.setHindi(hindi);
                bean.setScience(science);
                bean.setEnglish(english);
                bean.setValid(true);

            } else {
                bean.setValid(false);
            }
        }

        catch (Exception ex) {
            logger.error("Log In failed: An Exception has occurred! " + ex);
        }


public static StudentBean register(StudentBean bean) {
        Statement stmt = null;
        /**
         * method to search student
         * 
         * @533026
         * 
         */
        // preparing some objects for connection
        /*
         * String sName = bean.getStudentName(); String searchQuery =
         * "select * from Student where Student_Name='" + sName + "' "; //
         * "System.out.println" prints in the console; Normally used to trace
         * the process System.out.println("Your user name is " + sName);
         * System.out.println("Query: "+searchQuery);
         */
        PropertyConfigurator.configure("log4j.properties");
        try {
            // connect to DataBase
            currentCon = ConnectionManager.getConnection();

            // if user does not exist set the isValid variable to false

            // query for inserting into the table
            String sid = bean.getStudentId();
            String sn = bean.getStudentName();
            int ma = bean.getMaths();
            int sc = bean.getSocial();
            int hi = bean.getHindi();
            int si = bean.getScience();
            int eng = bean.getEnglish();

            String query = "update newstudent set std_name='" + sn + "',maths=" + ma + ",social="
                    + sc + ",hindi=" + hi + ",science=" + si + ",english=" + eng + " where std_id='" + sid + "'";
            // "logger" prints in to a file; Normally used to trace the process
            logger.info(query);
            pstmt = currentCon.prepareStatement(query);
            pstmt.executeUpdate();

        } catch (Exception ex) {
            logger.error("Log In failed: An Exception has occurred! " + ex);
        }


January 1, 2012 at 5:25 PM


/*
 *ConnectionManager
 *
 *
 *Version:1.0
 *
 *Date:25-Nov-2011
 *
 */
package com.student.dao;

import java.sql.*;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

public class ConnectionManager {

    static Connection con;
    static String url;
    static final Logger logger = Logger.getLogger(ConnectionManager.class);

    public static Connection getConnection() {
        PropertyConfigurator.configure("log4j.properties");
        try {
            String url = "jdbc:oracle:thin:@172.24.137.30:1521:ora10g";
            // assuming "DataSource" is your DataSource name

            Class.forName("oracle.jdbc.OracleDriver");

            try {
                con = DriverManager.getConnection(url, "e533121", "project1");

                // assuming your SQL Server's username is "username"
                // and password is "password"

            }

            catch (SQLException ex) {
                ex.printStackTrace();
            }
        }

        catch (ClassNotFoundException e) {// "logger" prints in to a file;
            // Normally used to trace the
            // process

            logger.error(e);
        }

        return con;
    }
}



createid:
/*
 *CollegeRegistrationDao
 *
 *
 *Version:1.0
 *
 *Date:31-Nov-2011
 *
 */
package com.student.dao;

import java.sql.*;

import com.student.beans.*;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

public class CreateIdDAO {
    static Connection currentCon = null;
    static ResultSet rs = null;
    static PreparedStatement pstmt = null;
    static ResultSet rs1 = null;
    static PreparedStatement pstmt1 = null;
    static final Logger logger = Logger.getLogger(CreateIdDAO.class);

    public static StudentBean register(StudentBean bean) {
        /**
         * method to search student
         * 
         * @533026,533121
         * 
         */
        // preparing some objects for connection
        Statement stmt = null;
        PropertyConfigurator.configure("log4j.properties");
        try {
            // connect to DataBase
            // connect to DataBase
            currentCon = ConnectionManager.getConnection();
            stmt = currentCon.createStatement();
            String getMax = "select Max(std_id) from studentids";
            rs1 = stmt.executeQuery(getMax);
            rs1.next();
            int maxId = rs1.getInt(1);
            System.out.println(maxId);
            int nextId = maxId + 1;
            String stdId = "S" + Integer.toString(nextId);
            String query1 = "insert into studentids values(?)";
            pstmt1 = currentCon.prepareStatement(query1);
            pstmt1.setInt(1, nextId);
            pstmt1.executeUpdate();
            bean.setStudentId(stdId);
        } catch (Exception ex) {// "logger" prints in to a file; Normally used
            // to trace the process

logger.error("Registration failed: An Exception has occurred! "
+ ex);
}

// exception handling
finally {
if (rs != null) {
try {
rs.close();
} catch (Exception e) {
}
rs = null;
}

if (stmt != null) {
try {
stmt.close();
} catch (Exception e) {
}
stmt = null;
}

if (currentCon != null) {
try {
currentCon.close();
} catch (Exception e) {
}

currentCon = null;
}
}

return bean;


}

}


registration:

try {
            // connect to DataBase
            // connect to DataBase
            currentCon = ConnectionManager.getConnection();
            String stdId=bean.getStudentId();
            System.out.println(stdId);
            // query for inserting into the table
            String query = "insert into newstudent(std_id,std_name,maths,social,hindi,science,english) values(?,?,?,?,?,?,?)";
            pstmt = currentCon.prepareStatement(query);
            // inserting values
            pstmt.setString(1,stdId);
            pstmt.setString(2,bean.getStudentName());
            pstmt.setInt(3, bean.getMaths());
            pstmt.setInt(4, bean.getSocial());
            pstmt.setInt(5, bean.getHindi());
            pstmt.setInt(6, bean.getScience());
            pstmt.setInt(7, bean.getEnglish());
            pstmt.executeUpdate();
            bean.setValid(true);

        }

delete:
try
        {


        String std = bean.getStudentId();
        PropertyConfigurator.configure("log4j.properties");
        String searchQuery = "delete from newstudent where std_id='"+ std + "'";
        bean.setValid(true);

        // // "logger" prints in to a file; Normally used to trace the process

        logger.info("Your employee id is " + std);

        logger.info("Query: " + searchQuery);

        }

        catch (Exception ex) {
            logger.error("Log In failed: An Exception has occurred! " + ex);
        }


search:

Statement stmt = null;

        String username = bean.getStudentId();

        String searchQuery = "select * from newstudent where std_id ='"
                + username + "' ";

        // "logger" prints in to a file; Normally used to trace the process

        logger.info("Student ID is " + username);
        logger.info("Query: " + searchQuery);

        try {
            // connect to DB
            currentCon = ConnectionManager.getConnection();
            stmt = currentCon.createStatement();
            rs = stmt.executeQuery(searchQuery);
            boolean more = rs.next();

            // if user does not exist set the isValid variable to false
            if (!more) {
                logger
                        .warn("Sorry, you are not a registered user! Please sign up first");
                bean.setValid(false);
            }

            // if user exists set the isValid variable to true
            else if (more) {
                String studentId = rs.getString("std_id");
                String studentName = rs.getString("std_NAME");
                int maths = rs.getInt("maths");
                int social = rs.getInt("social");
                int hindi = rs.getInt("hindi");
                int science = rs.getInt("science");
                int english = rs.getInt("english");
                bean.setStudentId(studentId);
                bean.setStudentName(studentName);
                bean.setMaths(maths);
                bean.setSocial(social);
                bean.setHindi(hindi);
                bean.setScience(science);
                bean.setEnglish(english);
                bean.setValid(true);
                int total=maths+social+hindi+science+english;
                if(total>=450){
                    bean.setGrade("A+");
                }
                if(total>=400 && total<=449){
                    bean.setGrade("A");
                }
                if(total>=350 && total<=399){
                    bean.setGrade("B");
                }
                if(total>=300 && total<=349){
                    bean.setGrade("C");
                }
                if(total>=250 && total<=299){
                    bean.setGrade("D");
                }
                if(total>=200 && total<=249){
                    bean.setGrade("E");
                }
                if(total<200){
                    bean.setGrade("Fail");
                }
                }

        }

profile and update:
Statement stmt = null;

        String username = bean.getStudentId();
        // query to select row from College using College_Id
        String searchQuery = "select * from newstudent where std_Id='"
                + username + "' ";
        // "logger" prints in to a file; Normally used to trace the process
        logger.info("Your user name is " + username);
        logger.info("Query: " + searchQuery);

        try {
            // connect to DataBase
            currentCon = ConnectionManager.getConnection();
            stmt = currentCon.createStatement();
            rs = stmt.executeQuery(searchQuery);
            boolean more = rs.next();
            // check for rows
            if (more) {

                String studentId = rs.getString("std_id");
                String studentName = rs.getString("std_NAME");
                int maths = rs.getInt("maths");
                int social = rs.getInt("social");
                int hindi = rs.getInt("hindi");
                int science = rs.getInt("science");
                int english = rs.getInt("english");
                bean.setStudentId(studentId);
                bean.setStudentName(studentName);
                bean.setMaths(maths);
                bean.setSocial(social);
                bean.setHindi(hindi);
                bean.setScience(science);
                bean.setEnglish(english);
                bean.setValid(true);

            } else {
                bean.setValid(false);
            }
        }

        catch (Exception ex) {
            logger.error("Log In failed: An Exception has occurred! " + ex);
        }


public static StudentBean register(StudentBean bean) {
        Statement stmt = null;
        /**
         * method to search student
         * 
         * @533026
         * 
         */
        // preparing some objects for connection
        /*
         * String sName = bean.getStudentName(); String searchQuery =
         * "select * from Student where Student_Name='" + sName + "' "; //
         * "System.out.println" prints in the console; Normally used to trace
         * the process System.out.println("Your user name is " + sName);
         * System.out.println("Query: "+searchQuery);
         */
        PropertyConfigurator.configure("log4j.properties");
        try {
            // connect to DataBase
            currentCon = ConnectionManager.getConnection();

            // if user does not exist set the isValid variable to false

            // query for inserting into the table
            String sid = bean.getStudentId();
            String sn = bean.getStudentName();
            int ma = bean.getMaths();
            int sc = bean.getSocial();
            int hi = bean.getHindi();
            int si = bean.getScience();
            int eng = bean.getEnglish();

            String query = "update newstudent set std_name='" + sn + "',maths=" + ma + ",social="
                    + sc + ",hindi=" + hi + ",science=" + si + ",english=" + eng + " where std_id='" + sid + "'";
            // "logger" prints in to a file; Normally used to trace the process
            logger.info(query);
            pstmt = currentCon.prepareStatement(query);
            pstmt.executeUpdate();

        } catch (Exception ex) {
            logger.error("Log In failed: An Exception has occurred! " + ex);
        }


January 1, 2012 at 5:27 PM


/*
 *college Registration Bean
 *
 *
 *Version:1.0
 *
 *Date:2-DEC-2011
 *
 */

package com.student.beans;

public class StudentBean {
    /**
     * Bean class for Student details
     * 
     * @author 533026,533121 version1.0 27/11/2011
     */
    // declaring attributes of the student table
    private String studentId;
    private String studentName;
    private int maths;
    private int social;
    private int hindi;
    private int science;
    private int english;
    private String grade;
    public boolean valid;

    // getter method for college id
    public String getStudentId() {
        return studentId;
    }

    // setter method for college id
    public void setStudentId(String newStudentId) {
        studentId = newStudentId;
    }

    // getter method for college name
    public String getStudentName() {
        return studentName;
    }

    // setter method for college name
    public void setStudentName(String newStudentName) {
        studentName = newStudentName;
    }

    // getter method for college authority
    public int getMaths() {
        return maths;
    }

    // setter method for college authority
    public void setMaths(int newMaths) {
        maths= newMaths;
    }

    // getter method for college address
    public int getSocial() {
        return social;
    }

    // setter method for college address
    public void setSocial(int newSocial) {
        social = newSocial;
    }

    // getter method for college address2
    public int getHindi() {
        return hindi;
    }

    // setter method for college address2
    public void setHindi(int newHindi) {
        hindi = newHindi;
    }

    // getter method for college city
    public int getScience() {
        return science;
    }

    // setter method for college city
    public void setScience(int newScience) {
        science = newScience;
    }

    // getter method for college state
    public int getEnglish() {
        return english;
    }

    // setter method for college state
    public void setEnglish(int newEnglish) {
        english = newEnglish;
    }
    // getter method for college state
    public String getGrade() {
        return grade;
    }

    // setter method for college state
    public void setGrade(String newGrade) {
        grade = newGrade;
    }


    // getter method for is valid
    public boolean isValid() {
        return valid;
    }

    // setter method for set valid
    public void setValid(boolean newValid) {
        valid = newValid;
    }

}


January 1, 2012 at 5:28 PM


package com.student.controllers;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.*;
import com.student.dao.*;
import com.student.beans.*;
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

/**
 * Servlet implementation class studentServlet
 */
public class studentServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    static final Logger logger = Logger.getLogger(studentServlet.class);

    /**
     * Default constructor. 
     */
    public studentServlet() {
        // TODO Auto-generated constructor stub
        PropertyConfigurator.configure("log4j.properties");
        logger.info("Entered Servlet");
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doPost(request,response);
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        try

        {
            HttpSession session = request.getSession(true);
            switch (Integer.parseInt(request.getParameter("name"))) {
            // case for college registration
            case 1:
                // creating object to java beans
                StudentBean createId = new StudentBean();
                createId = CreateIdDAO.register(createId);
                // storing the values in variables
                logger.info("Entered Case 1:Generation of ID");
                session.setAttribute("currentSessionUser", createId);
                String destination = "./jsp/studentReport.jsp";
                response.sendRedirect(response.encodeRedirectURL(destination));
                break;
            case 2:
                // creating object to java beans
                StudentBean registration = (StudentBean)(session.getAttribute("currentSessionUser"));
                // storing the values in variables
                logger.info("Entered Case 1:College Registration");
                registration.getStudentId();
                registration.setStudentName(request.getParameter("sn"));
                registration.setMaths(Integer.parseInt(request.getParameter("ma")));
                registration.setSocial(Integer.parseInt(request.getParameter("so")));
                registration.setHindi(Integer.parseInt(request.getParameter("hi")));
                registration.setScience(Integer.parseInt(request.getParameter("sc")));
                registration.setEnglish(Integer.parseInt(request.getParameter("eng")));
                registration = RegistrationDAO.register(registration);
                session.setAttribute("currentSessionUser", registration);
                String destination1 = "./jsp/collegeReportSuccess.jsp";
                response.sendRedirect(response.encodeRedirectURL(destination1));
                break;
            case 3:
                logger.info("Entered Case 2:College Search");
                StudentBean user = new StudentBean();
                user.setStudentId(request.getParameter("sid"));
                user = StudentSearchDao.search(user);
                if (user.isValid()) {
                    session.setAttribute("currentUser", user);
                    String destination2 = "./jsp/collegeSearchSuccess.jsp";
                    response.sendRedirect(response
                            .encodeRedirectURL(destination2)); // logged-in page
                } else {
                    String destination3 = "./jsp/invalidStudentSearch.jsp";
                    response.sendRedirect(response
                            .encodeRedirectURL(destination3)); // error page
                }
                break;
            case 4:
                logger.info("Entered Case 3:College Deletion");
                StudentBean collegeStudent = new StudentBean();
                collegeStudent.setStudentId(request.getParameter("sid"));

                collegeStudent = DeleteStudentDAO.login(collegeStudent);


                    session.setAttribute("currentSessionUser", collegeStudent);
                    response.sendRedirect("./jsp/collegeDeleteSuccess.jsp"); // logged-in
                    // page

                break;
            case 5:
                logger.info("Entered Case 4:Retreving college details");
                StudentBean studentProfile = new StudentBean();
                studentProfile.setStudentId(request.getParameter("sid"));
                studentProfile = StudentProfileDao.details(studentProfile);
                if (studentProfile.isValid()) {
                    session.setAttribute("current", studentProfile);
                    String destination2 = "./jsp/updateStudentProfile.jsp";
                    response.sendRedirect(response
                            .encodeRedirectURL(destination2));
                } else {
                    String destination2 = "./jsp/InvalidUpdateStudent.jsp";
                    response.sendRedirect(response
                            .encodeRedirectURL(destination2));
                }
                break;
            // case for updationg college details
            case 6:// creating object to java beans
                logger.info("Entered Case 5:Updating college details");
                StudentBean update = (StudentBean)(session.getAttribute("current"));
                // storing the values in variables
                update.setStudentId(update.getStudentId());
                update.setStudentName(request.getParameter("sn"));
                update.setMaths(Integer.parseInt(request.getParameter("ma")));
                update.setSocial(Integer.parseInt(request.getParameter("so")));
                update.setHindi(Integer.parseInt(request.getParameter("hi")));
                update.setScience(Integer.parseInt(request.getParameter("sc")));
                update.setEnglish(Integer.parseInt(request.getParameter("eng")));
                update = StudentUpdateDao.register(update);
                session.setAttribute("currentUpdateUser", update);
                String destination9 = "./jsp/updateStudentSuccess.jsp";
                response.sendRedirect(response.encodeRedirectURL(destination9));
                break;
        }

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


Related Tutorials/Questions & Answers:
CRUD DAO
CRUD DAO  how to create dao for create,read,update and delete?   /* *ConnectionManager * * *Version:1.0 * *Date:25-Nov-2011 * */ package com.student.dao; import java.sql.*; import org.apache.log4j.Logger
DAO Classes
DAO Classes  login page code for Dao classes
Advertisements
CRUD SERVLET
CRUD SERVLET  How to create a crud servlet?   Helper Class package com.nsep.user.helper; import java.sql.*; import java.util.logging.Logger; public class DataBaseUtil { Logger logger=Logger.getLogger("Logging
DAO Example
DAO Example  Dear Friends Could any one please give me any example of DAO application in struts? Thanks & Regards Rajesh
DAO - JDBC
DAO  what is dao ? and how to use it?  Hi Friend, The DAO is a pattern that provides a technique for separating object persistence and data access logic from any particular persistence mechanism or API. Thanks
DAO in Struts
DAO in Struts  Can Roseindia provide a simple tutorial for implementation of DAO with struts 1.2? I a link already exits plz do tell me. Thank you
doubt on DAO's
doubt on DAO's  hai frnds.... can anyoneexplain about how... our own plugin????? and please help me. how to use dao s while integrating struts with hibernate..??? actually what is the purpose of dao's ????? please help
doubt on DAO's
doubt on DAO's  hai frnds.... can anyoneexplain about how... our own plugin????? and please help me. how to use dao s while integrating struts with hibernate..??? actually what is the purpose of dao's ????? please help
For CRUD application - Spring
For CRUD application  Hi, Can i have Crud(create ,edit,update,delete the data in database ) code & search the eployee using "id or name" using Spring ,Hibernate and Mysql Thanks Raghavendra
dao pack
dao pack  package com.tsi.dao; import java.sql.*; import com.tsi.constants.*; public class DaoPack { public static Connection conn = null; public static Connection createConnection() { try
dao pack
dao pack  package com.tsi.dao; import java.sql.*; import com.tsi.constants.*; public class DaoPack { public static Connection conn = null; public static Connection createConnection() { try
dao
implementing DAO - Struts
, exam in 3 days, and just now i found out our lecturer post a demo on DAO implementation. It actually is a simple CRUD application , It has a table called Employee... divided into DAO factory Impl,employeeDAOImpl,DAOFactory,EmployeeDAO. "I strongly
spring DAO module turorial
spring DAO module turorial  how to integrate springDAO and spring webMVC
CRUD operations in spring mvc 2.5
CRUD operations in spring mvc 2.5  Hi, I want to do CRUD operations on jquery datatable such as edit delete select and add row. I am using spring mvc 2.5. How can I do this. Thanks in advance
crud operations with foreign key constraint.
crud operations with foreign key constraint.  I neeed to know how to perform crud operations in mysql with foreign key constraint using mvc architecture i.e using servlet jsp and bean. please provide all the code so that i can
CRUD application in hibernate annotation
CRUD application in hibernate annotation       In this section, you will learn how to develop a CRUD application...  Follows the following steps for developing the CRUD application
Basic CRUD operations
Basic CRUD operations  LOGIC SERVLET package com.tcs.ilp.h51.servlet; import java.io.IOException; import java.sql.SQLException; import java.util.ArrayList; import javax.servlet.RequestDispatcher; import
Basic CRUD operations
Basic CRUD operations  LOGIC SERVLET package com.tcs.ilp.h51.servlet; import java.io.IOException; import java.sql.SQLException; import java.util.ArrayList; import javax.servlet.RequestDispatcher; import
Basic CRUD operations
Basic CRUD operations  LOGIC SERVLET package com.tcs.ilp.h51.servlet; import java.io.IOException; import java.sql.SQLException; import java.util.ArrayList; import javax.servlet.RequestDispatcher; import
JPA Crud
JPA Crud       In this section we will show you how to develop simple CRUD application using JPA... the application. This simple JPA CRUD application can be the base for your future
JSP CRUD Application
Create JSP CRUD Application and run on Tomcat 7 In this section we will discuss about how to create a simple crud application in JSP using Eclipse IDE. We.... CRUD is basically used in the context of database driven application where
DAO DTO design pattern
DAO DTO design pattern  Hi,using dao and dto i want to perform insert,update and delete operation.and the data should navigate from 1 frame 2 another.that page should b smthng like this: <%@ page language="java" import
DAO DTO design pattern
DAO DTO design pattern  Hi,using dao and dto i want to perform insert,update and delete operation.and the data should navigate from 1 frame 2 another.that page should b smthng like this: <%@ page language="java" import
DAO DTO design pattern
DAO DTO design pattern  Hi,using dao and dto i want to perform insert,update and delete operation.and the data should navigate from 1 frame 2 another.that page should b smthng like this: <%@ page language="java" import
DAO DTO design pattern
DAO DTO design pattern  Hi,using dao and dto i want to perform insert,update and delete operation.and the data should navigate from 1 frame 2 another.that page should b smthng like this: <%@ page language="java" import
JPA 2.1 CRUD examples
Learn how to create CRUD operation examples in JPA 2.1 In this section you will learn how to create example program that forms CRUD operations against database. The CRUD application (example) in JPA is very important topic which
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
DAO,DTO,VO Design patterns
DAO,DTO,VO Design patterns  explain dao,dto,vo design patterns in strut 1.3?   Data Access Object (DAO) pattern is the most popular design patterns. It is used when you want to separate your presentation code from
How to make a CRUD without using SQL Server? by just using your GUI? (CRUD = Creating, Register, Update, Delete)
How to make a CRUD without using SQL Server? by just using your GUI? (CRUD = Creating, Register, Update, Delete)  well I got a Program that can... a CRUD again without using SQL Server. how to make it? please help
DAO Layer explained
DAO Layer explained       In this section we will explain you the DAO Layer of our application.   DAO Layer Explained   DAO stand for Data
How to perform CRUD operations using gwt on Restlet server 2.0
How to perform CRUD operations using gwt on Restlet server 2.0  I want to perform CRUD operation using gwt on restlet server 2.0. The CRUD operations are like create, read, update, delete operations.Any generic code
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
CRUD application in JPA
CRUD application in JPA      ... a CRUD application in JPA (Java Persistence APIs).  Table name... the CRUD application in JPA : Step 1: The hibernate.cfg.xml
Creating and running the JPA CRUD application
Creating and running the JPA CRUD application   ... different project artifacts for JPA CRUD demo example code. After completing... the CRUD demo application. Following the following steps to create the JPA
Creating Data Access Object (DAO) Design Pattern
Creating Data Access Object (DAO) Design Pattern Data Access Object... code contains in  DAO and it provides a simple interface to access the data. In DAO you need to create the Connection factory class. This class contains
login dao file for referece (source code for reference)
login dao file for referece (source code for reference)  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <
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 to dao n bean classes with jsp
How to connect to dao n bean classes with jsp  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
Session #1 - Hibernate introduction and creating CRUD application
Session #1 - Video tutorial of Hibernate introduction and creating CRUD... and teaches you how to create simple CRUD application. Hibernate is one..., you will learn the basics of Hibernate and then create a simple CRUD
Understanding Spring Struts Hibernate DAO Layer
Understanding Spring Struts Hibernate DAO Layer... Hibernate DAO Layer   The Data Access Object for this application is written... access object. The Hibernate DAO consists applicationContext-hibernate.xml
How sql Queries possible in DAO without creating Database connections - Java Beginners
How sql Queries possible in DAO without creating Database connections  In DAO we are writting sql queries , how it is possible without creating and closing database connections
Data Access object (DAO) Design Pattern
. The DAO design pattern completely  hides the data access implementation... the DAO to adopt different access scheme without affecting to business logic or its.... The DAO design pattern consists of some factory classes, DAO interfaces
net.roseindia.dao
This section contains the DAO interface and its implementation class
Creating and running the JPA CRUD application
Creating and running the JPA CRUD application       In this section we will develop the project articles for JPA application using NetBeans IDE. Follow
Developing JPA CURD Application with Eclipse
will learn how to develop JPA CRUD application in eclipse IDE. Eclipse is one... the required library and then easily execute the JPA CRUD examples. Let's
 

 

 

DMCA.com