0% found this document useful (0 votes)
24 views1 page

Insert

Uploaded by

var1989
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views1 page

Insert

Uploaded by

var1989
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

pageEncoding="ISO-8859-1" import ="java.sql.*"%>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.or
g/TR/html4/loose.dtd">
<%!
Connection con =null;
ResultSet rs;
PreparedStatement psnt;
%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert a new user</title>
</head>
<body>
<%
//loading the drivers
Class.forName("net.sourceforge.jtds.jdbc.Driver");
//Initailizing the connection object
con =DriverManager.getConnection("jdbc:jtds:sqlserver://Traina:1433/varun","sa",
"trNg*");
//get the values from the previous page
String empn=request.getParameter("empN");
String empid1=request.getParameter("usrid");
String pass=request.getParameter("pas");
String usrtp=request.getParameter("usrtp");
System.out.println(empn);
System.out.println(empid1);
System.out.println(pass);
System.out.println(usrtp);
//then preparing the statement for inserting the values into the table
psnt=con.prepareStatement("INSERT empVar VALUES(?,?,?,?)");
//psnt=con.prepareStatement("INSERT INTO empVar VALUES (empId=?,empName=?,passwo
rd=?,userType=?)");
psnt.setString(1,empn);
psnt.setString(2,empid1);
psnt.setString(3,pass);
psnt.setString(4,usrtp);
//Executing the query
psnt.executeUpdate();
%>
</body>
</html>

You might also like