-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstore.jsp
35 lines (34 loc) · 1.07 KB
/
store.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<%@ page import="java.sql.*"%>
<%@page import="java.io.PrintWriter"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%
String firstname=request.getParameter("fname");
String middlename=request.getParameter("mname");
String lastname=request.getParameter("lname");
String gender=request.getParameter("gender");
String age=request.getParameter("age");
String phone=request.getParameter("phone");
try{
Class.forName("oracle.jdbc.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","haransh","haransh");
PreparedStatement ps=con.prepareStatement("insert into register values(?,?,?,?,?,?)");
ps.setString(1,firstname);
ps.setString(2,middlename);
ps.setString(3,lastname);
ps.setString(4,age);
ps.setString(5,gender);
ps.setString(6,phone);
int x= ps.executeUpdate();
if(x!=0){
out.println("registered");
response.sendRedirect("registered.html");
}
else
out.println("somthing went wrong");
}
catch(Exception e)
{
out.println(e);
}
%>