Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%--
- Document : processOrder
- Created on : Dec 20, 2017, 6:05:50 AM
- Author : Sam
- --%>
- <%@page import="java.sql.Statement"%>
- <%@page import="java.sql.DriverManager"%>
- <%@page import="java.sql.Connection"%>
- <%--
- Document : logout
- Created on : Apr 28, 2017, 9:38:18 PM
- Author : Sam
- --%>
- <%
- String UserName = "";
- if (((String) session.getAttribute("username1")) != null) {
- UserName = (String) session.getAttribute("username1");
- }
- String order1 = "";
- String qty1 = "";
- if ((((String) session.getAttribute("order1")) != null) && (((String) session.getAttribute("qty1")) != null)) {
- order1 = ((String) session.getAttribute("order1"));
- qty1 = ((String) session.getAttribute("qty1"));
- }
- String order2 = "";
- String qty2 = "";
- if ((((String) session.getAttribute("order2")) != null) && (((String) session.getAttribute("qty2")) != null)) {
- order2 = ((String) session.getAttribute("order2"));
- qty2 = ((String) session.getAttribute("qty2"));
- }
- String order3 = "";
- String qty3 = "";
- if ((((String) session.getAttribute("order3")) != null) && (((String) session.getAttribute("qty3")) != null)) {
- order3 = ((String) session.getAttribute("order3"));
- qty3 = ((String) session.getAttribute("qty3"));
- }
- String order4 = "";
- String qty4 = "";
- if ((((String) session.getAttribute("order4")) != null) && (((String) session.getAttribute("qty4")) != null)) {
- order4 = ((String) session.getAttribute("order4"));
- qty4 = ((String) session.getAttribute("qty4"));
- }
- String order5 = "";
- String qty5 = "";
- if ((((String) session.getAttribute("order5")) != null) && (((String) session.getAttribute("qty5")) != null)) {
- order5 = ((String) session.getAttribute("order5"));
- qty5 = ((String) session.getAttribute("qty5"));
- }
- String order6 = "";
- String qty6 = "";
- if ((((String) session.getAttribute("order6")) != null) && (((String) session.getAttribute("qty6")) != null)) {
- order6 = ((String) session.getAttribute("order6"));
- qty6 = ((String) session.getAttribute("qty6"));
- }
- String order7 = "";
- String qty7 = "";
- if ((((String) session.getAttribute("order7")) != null) && (((String) session.getAttribute("qty7")) != null)) {
- order7 = ((String) session.getAttribute("order7"));
- qty7 = ((String) session.getAttribute("qty7"));
- }
- String order8 = "";
- String qty8 = "";
- if ((((String) session.getAttribute("order8")) != null) && (((String) session.getAttribute("qty8")) != null)) {
- order8 = ((String) session.getAttribute("order8"));
- qty8 = ((String) session.getAttribute("qty8"));
- }
- String order9 = "";
- String qty9 = "";
- if ((((String) session.getAttribute("order9")) != null) && (((String) session.getAttribute("qty9")) != null)) {
- order9 = ((String) session.getAttribute("order9"));
- qty9 = ((String) session.getAttribute("qty9"));
- }
- String order10 = "";
- String qty10 = "";
- if ((((String) session.getAttribute("order10")) != null) && (((String) session.getAttribute("qty10")) != null)) {
- order10 = ((String) session.getAttribute("order10"));
- qty10 = ((String) session.getAttribute("qty10"));
- }
- Connection connection = null;
- String status = "Pending";
- try {
- Class.forName("org.gjt.mm.mysql.Driver");
- String url = "jdbc:mysql://localhost/dbburgenator";
- String user = "root";
- String pwd = "";
- connection = DriverManager.getConnection(url, user, pwd);
- Statement statement = connection.createStatement();
- //INSERT DATA TO TABLE order.
- String queryInsert1 = "INSERT INTO orders "
- + "(userName, order1, qty1, order2, qty2, order3, qty3, order4, qty4, order5, qty5, order6, qty6, order7, qty7, order8, qty8, order9, qty9, order10, qty10, status)"
- + "VALUES "
- + "('" + UserName + "', '" + order1 + "', '" + qty1 + "', '" + order2 + "', '" + qty2 + "', '" + order3 + "', '" + qty3 + "', '" + order4 + "', '" + qty4 + "', '" + order5 + "', '" + qty5 + "', '" + order6 + "', '" + qty6 + "', '" + order7 + "', '" + qty7 + "', '" + order8 + "', '" + qty8 + "', '" + order9 + "', '" + qty9 + "', '" + order10 + "', '" + qty10 + "', '" + status + "')";
- int i = statement.executeUpdate(queryInsert1);
- if (i == 1) {
- out.println("<script>alert('ORDER PROCESSED!!! ');document.location.href='index.jsp';</script>");
- } else {
- out.println("<script>alert('ORDER FAIL TO PROCESSED!!! ');window.history.back();</script>");
- }
- if (connection != null) {
- connection.close();
- }
- } catch (Exception e) {
- out.println("Error" + e);
- System.out.println("Error" + e);
- } finally {
- if (null != connection) {
- connection.close();
- }
- }
- %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement