Update through jsp.


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

<html>
<head>
</head>
<body>
<%
int k=Integer.parseInt(request.getParameter("i"));
String n=request.getParameter("n");
String p=request.getParameter("p");
String e=request.getParameter("e");
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/naveen","root","");
PreparedStatement stmt=con.prepareStatement("update department set name='"+n+"',password='"+p+"',emailid='"+e+"' where id="+k);
int j=stmt.executeUpdate();
if(j>0)
{
out.print("updated");
%>
<a href="view.jsp">View All Records</a>
<%
}
else
{
out.print("not updated");
%>
<a href="view.jsp">View All Records</a>
<%
}
}
catch(Exception ex)
{
out.print(ex);
}
%>
</body>
</html>

Popular posts from this blog

Simple Sign up design. Android.

Cart page design in android.

Set Date on jDateChooser and retrieve record from database.