-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSBI_Interface1.jsp
78 lines (76 loc) · 2.1 KB
/
SBI_Interface1.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
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="java.sql.*"
import = "java.io.*"
import = "java.util.*"
import = "javax.sql.*"
import = "java.sql.ResultSet"
import = "java.sql.Statement"
import = "java.sql.Connection"
import = "java.sql.DriverManager"
import = "java.sql.SQLException" %>
<%! String[] billname;
String balance;
String Ref_ID;
%>
<%
Connection con= null;
PreparedStatement ps = null;
PreparedStatement ps2=null;
ResultSet rs1 = null;
String driverName = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/TEST";
String user = "root";
String dbpsw = "ANANY";
String sql="select * from sbiinfo where ref_id="+session.getAttribute("id");
try
{
Class.forName(driverName);
con = DriverManager.getConnection(url, user, dbpsw);
Statement stmt= con.createStatement();
ps2=con.prepareStatement("update sbiinfo set balance = ? where ref_id="+session.getAttribute("id"));
ps = con.prepareStatement(sql);
rs1 = ps.executeQuery(sql);
if(rs1.next())
{
Ref_ID=rs1.getString("ref_id");
balance= rs1.getString("balance");
}
else
response.sendRedirect("error.jsp");
rs1.close();
ps.close();
}
catch(SQLException sqe)
{
out.println(sqe);
}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Payment Interface</title>
</head>
<body>
<%int total=Integer.parseInt(request.getParameter("Update"));
int SBIbalance=Integer.parseInt(balance);
String[] billname= request.getParameterValues("BillName");%>
<%for(int i=0;i<billname.length;i++){%>
<form action="Payment_Success1.jsp" method="get">
<input name="BillName" type="hidden" value=<%=billname[i] %>>
<input type="submit" value="Submit">
</form>
<%} %>
<%
session.setAttribute("BillName",billname);
if(SBIbalance>=total)
{
ps2.setInt(1,SBIbalance-total);
ps2.executeUpdate();
response.sendRedirect("Payment_Success1.jsp");
}
else
%>
</body>
</html>