Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- addtrainee.jsp
- <%--
- Document : addtrainee
- Created on : Mar 14, 2017, 4:12:58 PM
- Author : Lenovo
- --%>
- <%@page import = "java.sql.Connection"%>
- <%@page import = "java.sql.DriverManager"%>
- <%@page import = "java.sql.Statement"%>
- <%@page contentType="text/html" pageEncoding="UTF-8"%>
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
- <title>ADD TRAINEE</title>
- </head>
- <body>
- <%
- Connection conn = null;
- try
- {
- Class.forName("org.gjt.mm.mysql.Driver");
- String url = "jdbc:mysql://localhost/traineemanagementsystem";
- String user = "root";
- String pwd = "";
- conn = DriverManager.getConnection(url,user,pwd);
- Statement s = conn.createStatement();
- String name = request.getParameter("traineeNAME");
- String city = request.getParameter("traineeCITY");
- String query = "INSERT INTO trainee"
- + "(traineeNAME, traineeCITY)"+ "VALUES"
- + "'('" + name+ "', '" + city+"')'";
- int i = s.executeUpdate(query);
- if(i==1)
- System.out.println("TRAINEE RECORDED");
- else
- System.out.println("TRAINEE NOT RECORDED");
- if(conn!=null)
- conn.close();
- }
- catch (Exception e){response.sendError(HttpServletResponse.SC_NOT_FOUND);}
- finally
- {
- if(null != conn)
- {conn.close();}
- }
- %>
- <h1>New Trainee Successfully Inserted!!!</h1>
- <br>
- <a href=traineeForm.html>Add New Trainee</a>
- <a href=traineeReport.jsp>List Of Trainee</a>
- </body>
- </html>
Add Comment
Please, Sign In to add comment