hey buddy's, i'm creating the program of employee details and i will inserted the fields are ADD,UPDATE,DELETE,EXIT,. I hope the all thing to find the exact solutions but, particular one thing only, that was UPDATE and these are the following some tips and code:
1.the input is not going store in database and,
2.the file is not updated. advance congrats for finding the solutions...
<html>
<head>
<title>
UPDATING DETAILS ABOUT EMPLOYEE
</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
</head>
<body>
<h3>ENTER THE EMPLOYEE DETAILS</h3><br>
<form action="editEmployee.jsp" name="UpdateForm" method="post">
<table cellspacing="1" cellpadding="1" border="1" WIDTH=90%>
<tr>
<td align="center">YOUR EMPLOYEE ID:</td><td align="center"><B><%= request.getParameter("emp_id")%></B></td>
</tr>
<tr>
<td align="center">EMPLOYEE NAME:</td>
<td align="center"><input type="text" name="EmployeeName"></td>
</tr>
<tr>
<td align="center"> EMPLOYEE NATIONLITY:</td>
<td align="center"><input type="text" name="Nationality"></td>
</tr>
</table><br><br>
<input type="submit" value="UPDATE" name="method" class="button" >
<input type="reset" value="CLEAR">
<input type="button" name="method" value="BACK TO LIST" class="button" onclick="location.href='Employeelist.jsp'"/>
</form>
<%@ page import="java.sql.*" %>
<%@ page import="java.sql.DriverManager.*" %>
<%@ page import="java.sql.Statement.*" %>
<%@ page import="java.io.*" %>
<%
String EmployeeName=request.getParameter("EmployeeName");
int Employee_id=Integer.parseInt(request.getParameter("emp_id"));
String Nationality=request.getParameter("Nationality");
PreparedStatement ps;
Connection con=null;
String driverName="com.mysql.jdbc.Driver";
String connectionUrl="jdbc:mysql://localhost:3306/";
String user="root";
String password="sarakrish";
String dbName="employee";
try{
Class.forName(driverName);
con=DriverManager.getConnection(connectionUrl+dbName,user,password);
ps=con.prepareStatement("update employees set EmployeeName=?, Nationlity=? where Employee_id=?");
ps.setString(1, EmployeeName);
ps.setInt(2, Employee_id);
ps.setString(3, Nationality);
ps.executeUpdate();
}
catch(ClassNotFoundException e)
{
out.print("ClassNotFoundException:"+e.getMessage());
e.printStackTrace();
}
%>
</body>
</html>