employee records

employee records

Pl give one script like i will creat one table name Emp_master and column name like Empcode, Empname.

I like one form where I will enter New record and another form like emp_code query and update or delete

and one report like details of employee

thanks

View Answers

August 10, 2011 at 3:23 PM

1)application.jsp:

<%@ page import="java.sql.*" %>
<html>
<head>
<script language="javascript">
function editRecord(id){
    var f=document.form;
    f.method="post";
    f.action='edit.jsp?id='+id;
    f.submit();
}
function deleteRecord(id){
    var f=document.form;
    f.method="post";
    f.action='delete.jsp?id='+id;
    f.submit();
}
</script>
</head>
<body>

<br><br>
<form method="post" name="form">
<table border="1">
<tr><th>Name</th><th>Address</th><th>Contact No</th><th>Email</th></tr>
<%
Connection con = null;
String url = "jdbc:mysql://localhost:3306/";
String db = "test";
String driver = "com.mysql.jdbc.Driver";
String userName ="root";
String password="root";

int sumcount=0;
Statement st;
try{
Class.forName(driver).newInstance();
con = DriverManager.getConnection(url+db,userName,password);
String query = "select * from employee";
st = con.createStatement();
ResultSet rs = st.executeQuery(query);
%>
<%
while(rs.next()){
%>
<tr><td><%=rs.getString(2)%></td>
<td><%=rs.getString(3)%></td>
<td><%=rs.getString(4)%></td>
<td><%=rs.getString(5)%></td>
<td><input type="button" name="edit" value="Edit" style="background-color:green;font-weight:bold;color:white;" onclick="editRecord(<%=rs.getString(1)%>);" ></td>
<td><input type="button" name="delete" value="Delete" style="background-color:red;font-weight:bold;color:white;" onclick="deleteRecord(<%=rs.getString(1)%>);" ></td>
</tr>
<%
}
%>
<%
}
catch(Exception e){
e.printStackTrace();
}
%>
</table>
</form>
</body>
</html>

2)edit.jsp:

<%@page language="java"%>
<%@page import="java.sql.*"%>
<form method="post" action="update.jsp">
<table border="1">
<tr><th>Name</th><th>Address</th><th>Contact No</th><th>Email</th></tr>
<%
String id=request.getParameter("id");
int no=Integer.parseInt(id);
int sumcount=0;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
String query = "select * from employee where id='"+no+"'";
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery(query);
while(rs.next()){
%>
<tr>
<td><input type="text" name="name" value="<%=rs.getString("name")%>"></td>
<td><input type="text" name="address" value="<%=rs.getString("address")%>"></td>
<td><input type="text" name="contact" value="<%=rs.getInt("contactNo")%>"></td>
<td><input type="text" name="email" value="<%=rs.getString("email")%>"></td>
<td><input type="hidden" name="id" value="<%=rs.getString(1)%>"></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Update" style="background-color:#49743D;font-weight:bold;color:#ffffff;"></td>
</tr>
<%
}
}
catch(Exception e){}
%>
</table>
</form>

August 10, 2011 at 3:24 PM

continue..

3)update.jsp:

<%@page import="java.sql.*"%>
<%
String ide=request.getParameter("id");
int num=Integer.parseInt(ide);
String name=request.getParameter("name");
String address=request.getParameter("address");
int contact=Integer.parseInt(request.getParameter("contact"));
String email=request.getParameter("email");
try{
Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root", "root");
Statement st=null;
st=conn.createStatement();
st.executeUpdate("update employee set name='"+name+"',address='"+address+"',contactNo="+contact+",email='"+email+"' where id='"+num+"'");
response.sendRedirect("/examples/jsp/application.jsp");
}
catch(Exception e){
System.out.println(e);
}
%>

4)delete.jsp:

<%@page import="java.sql.*"%>
<%

String id=request.getParameter("id");
int no=Integer.parseInt(id);
int sumcount=0;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
Statement st = conn.createStatement();
st.executeUpdate("DELETE FROM employee WHERE id = '"+no+"'");
response.sendRedirect("application.jsp");
}
catch(Exception e){}
%>









Related Tutorials/Questions & Answers:
employee records
employee records  Pl give one script like i will creat one table name Emp_master and column name like Empcode, Empname. I like one form where I... and one report like details of employee thanks
employee records
employee records  Pl give one script like i will creat one table name Emp_master and column name like Empcode, Empname. I like one form where I... and one report like details of employee thanks
Advertisements
employee records
employee records  Pl give one script like i will creat one table name Emp_master and column name like Empcode, Empname. I like one form where I... and one report like details of employee thanks
displaying employee records and their images problem - JSP-Servlet
displaying employee records and their images problem  hi, Thanks for your reply to my question. The code you sent to me yesterday was not working. it doesn't display any record and image. Please, help me out urgent
application for an Employee
: in this page it should modify employee data and persist in DB 3.DISPLAY:it should display all the records and should have the option to delete a record
Add Employee
Add Employee  coding for adding an employee
Adding an employee
Adding an employee  coding for adding an employee
Employee Salaries
Employee Salaries  Define a class Employee with the following properties. Every Employee has a name and a salary. The constructor creates an Employee... the salary of the Employee to zero. The method getinfo() will return the current
EMPLOYEE - SQL
EMPLOYEE  CALCULATE EMPLOYEE SALARY  Hi friend, Please give the full details of Problem. Thanks
Employee form
Employee form  In employee form emp Id id after any data iserted is incremented for oher data insertion. insert, delete, update buttons when we cleak the select buttoun then the created table data iserted automaticaly
Employee Salaries
Employee Salaries  Define a class Employee with the following properties. Every Employee has a name and a salary. The constructor creates an Employee... the salary of the Employee to zero. The method getinfo() will return the current
Employee Salaries
Employee Salaries  Define a class Employee with the following properties. Every Employee has a name and a salary. The constructor creates an Employee... the salary of the Employee to zero. The method getinfo() will return the current
Employee Salaries
Employee Salaries  Define a class Employee with the following properties. Every Employee has a name and a salary. The constructor creates an Employee... the salary of the Employee to zero. The method getinfo() will return the current
Employee Salaries
Employee Salaries  Define a class Employee with the following properties. Every Employee has a name and a salary. The constructor creates an Employee... the salary of the Employee to zero. The method getinfo() will return the current
Employee Salaries
Employee Salaries  Define a class Employee with the following properties. Every Employee has a name and a salary. The constructor creates an Employee... the salary of the Employee to zero. The method getinfo() will return the current
employee progarm
employee progarm  Hai, I have developed a code for an employee program by using jtext fields and buttons,it has no errors but while we are compiling it it is saying that "Exception in thread "main
coding for employee management system
coding for employee management system  coding for employee management system
Employee Management System
Employee Management System  coding for employee management system
Employee Management System
Employee Management System  coding for employee management system
display the employee name
display the employee name  when i will select one employee designation based on that employee designation display the particular designation employee name display in another select box how it possible using servlet and mysql
Employee Management Sysem
Employee Management Sysem  coding for Daoclass Login Page Validation
program on employee details
program on employee details  to write a program on displaying the employee details like empid,empname,wonno,location,leave type by using the text fields in java swings
Auto Generated Employee ID
Auto Generated Employee ID  Hello Everyone I want to generate an ID like (SCS-0001) and then it should be auto incremented each time a new employee add page is opens. I am using My Sql database
PHP WHERE clause example to fetch records from Database Table
on the MYSQL Server and will fetch the results from the database table employee
compute the daily wage of an employee.
compute the daily wage of an employee.   B. Write a JavaScript program that would input Employee Name, Rate per hour, No. of hours worked and will compute the daily wage of an employee. If the number of hours worked exceeds
compute the daily wage of an employee.
compute the daily wage of an employee.   B. Write a JavaScript program that would input Employee Name, Rate per hour, No. of hours worked and will compute the daily wage of an employee. If the number of hours worked exceeds
ModuleNotFoundError: No module named 'records'
ModuleNotFoundError: No module named 'records'  Hi, My Python... 'records' How to remove the ModuleNotFoundError: No module named 'records... to install padas library. You can install records python with following command
Generate Employee ID (SCS-0001,SCS-0002......)
Generate Employee ID (SCS-0001,SCS-0002......)  Hello everyone i am beginner in java and i am working on my major project I want to generate bill number and employee number like SCS-0001 and so on and bill number like SCS/'date
JDBC : Duplicate records in a table
records in a table.. Employee Name having duplicate names : Linda Roxi...JDBC : Duplicate records in a table In this tutorial, you will learn how to find the duplicate records in a table. Duplicate records in a table : You
deleting all records from a table in mysql
deleting all records from a table in mysql  Hi, I am finding code for deleting all records from a table in mysql. How to delete all rows in mysql table? Thanks   Hi, If you have a table called EMPLOYEE then you can
deleting all records from a table in mysql
deleting all records from a table in mysql  Hi, I am finding code for deleting all records from a table in mysql. How to delete all rows in mysql table? Thanks   Hi, If you have a table called EMPLOYEE then you can
multiple records on same panel
multiple records on same panel  i have multiple access of records and i want to display all of them at one panel.Each time a new panel opens for a keyrecord , i want just to show records on same panel or frame, whatever u can
Search million records????
Search million records????  How to get fast search results from a table with over 10 million record??? 11g Oracle DB
display 1000 of records - Struts
display 1000 of records  how to display 1000 of records using next... that we can display any number of records. Implement a sample   We have pagination concept in Java. Using that we can display any number of records
Employee Details - JSP-Servlet
Employee Details  Respected Sir/Madam, Thanks for your response. Regarding that alert box problem what I have decided is to include the contents of process.jsp in the home page itself without any submit button
store the employee ID,name,login time and logout time of the employee in database
store the employee ID,name,login time and logout time of the employee in database  hello...I want to store the employee ID,name,login time and logout time of the employee along with the time difference between these two
duplicate records inserting
duplicate records inserting  in the application i have provided the text filed on entering and submit the record is getting inserted. my question... shashi kumar with the same between them ,records get inserted ,now when i try
Mysql Find Duplicate Records
Mysql Find Duplicate Records       Mysql Find Duplicate Records is used to find the duplicate Records... an example from 'Mysql Find Duplicate Records'. To grasp and understand example
Data displaying with limited records in jsp
Data displaying with limited records in jsp  How to display table with limited 10 records , after clicking next button another 10 records from database upto last record please help me
how to display records from database
how to display records from database  I want to display records from database in tables, the database is having 2000 records and i want to display 20 records at a time and to use next and previous link buttons to show
ModuleNotFoundError: No module named 'columnar_records'
ModuleNotFoundError: No module named 'columnar_records'  Hi, My... named 'columnar_records' How to remove the ModuleNotFoundError: No module named 'columnar_records' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'data-records'
ModuleNotFoundError: No module named 'data-records'  Hi, My Python... 'data-records' How to remove the ModuleNotFoundError: No module named 'data-records' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'records-mover'
ModuleNotFoundError: No module named 'records-mover'  Hi, My... 'records-mover' How to remove the ModuleNotFoundError: No module named 'records-mover' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'aim-records'
ModuleNotFoundError: No module named 'aim-records'  Hi, My Python... 'aim-records' How to remove the ModuleNotFoundError: No module named 'aim-records' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'columnar_records'
ModuleNotFoundError: No module named 'columnar_records'  Hi, My... named 'columnar_records' How to remove the ModuleNotFoundError: No module named 'columnar_records' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'data-records'
ModuleNotFoundError: No module named 'data-records'  Hi, My Python... 'data-records' How to remove the ModuleNotFoundError: No module named 'data-records' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'flask-records'
ModuleNotFoundError: No module named 'flask-records'  Hi, My... 'flask-records' How to remove the ModuleNotFoundError: No module named 'flask-records' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'invenio-records'
ModuleNotFoundError: No module named 'invenio-records'  Hi, My... named 'invenio-records' How to remove the ModuleNotFoundError: No module named 'invenio-records' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'invisibleroads-records'
ModuleNotFoundError: No module named 'invisibleroads-records'  Hi...: No module named 'invisibleroads-records' How to remove the ModuleNotFoundError: No module named 'invisibleroads-records' error? Thanks   Hi
to write a program to display the employee details..
to write a program to display the employee details..  To dipslay the employee details like empid,empname,salary,wonno bye using java swings.by... the employee details.please send me the code .it's urgent.send me as soon as possible

Ads