-
Notifications
You must be signed in to change notification settings - Fork 1
/
addsub.jsp
92 lines (74 loc) · 2.09 KB
/
addsub.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<%@ page language="java" session="true" import="java.sql.*" %>
<jsp:useBean class="connection.Conn" id="con" scope="session"/>
<%
int sem=0;
int allo=0;
Statement stmt=con.getcon();
System.out.println("-add subject.jsp-------");
String s=null,m=null,b=null,c=null;
String branch=session.getAttribute("branch").toString();
System.out.println("-ALERT------"+branch);
String subname=request.getParameter("subname");
String subcode=request.getParameter("subcode");
String subid=request.getParameter("subid");
System.out.println("-ALERT------");
System.out.println("-------branch-->"+branch);
System.out.println("-------subname-->"+subname);
System.out.println("-------subcode-->"+subcode);
System.out.println("-----subid----->"+subid);
try
{
if(branch.equals("COMPUTER SCIENCE"))
b="CS";
if(branch.equals("ELECTRONICS AND COMMUNICATION"))
b="EC";
if(branch.equals("ELECTRICAL SCIENCE"))
b="EE";
if(branch.equals("ELECTRONICS AND INSTRUMENTATION"))
b="EI";
if(branch.equals("MECHANICAL ENGINEERING"))
b="ME";
System.out.println("---------bb->"+b);
String q1="SELECT SUBJECTNAME,SUBJECTCODE FROM "+b+"SUBJECT where SUBJECTID='"+subid+"'";
System.out.println("----->"+q1);
ResultSet rn=stmt.executeQuery(q1);
System.out.println("-->query--executed--");
while(rn.next())
{
s=rn.getString(1);
System.out.println("-already---exist->"+s);
c=rn.getString(2);
System.out.println("-already---exist->"+c);
}
String q3="SELECT SUBJECTNAME,SUBJECTID FROM "+b+"SUBJECT where SUBJECTCODE='"+subcode+"'";
System.out.println("----->"+q1);
ResultSet rc=stmt.executeQuery(q3);
while(rc.next())
{
s=rc.getString(1);
System.out.println("-already---exist->"+s);
c=rc.getString(2);
System.out.println("-already---exist->"+c);
}
if(s!=null)
{
System.out.println("----->ALREDY EXIST--");
m="exist";
}
else
{
System.out.println("---->else");
String q2="INSERT INTO "+b+"SUBJECT VALUES('"+subname+ "','"+subcode+"','"+subid+"')";
System.out.println("----->"+q2);
stmt.execute(q2);
//m=Integer.toString(s);
System.out.println("---->query executed");
m="added";
}
out.write(m);
}
catch(Exception e)
{
System.out.println("-->"+e);
}
%>