Guest User

Untitled

a guest
Jan 18th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. <%--
  2. Document : insert
  3. Created on : Jan 18, 2019, 2:40:38 PM
  4. Author : Jonathan
  5. --%>
  6.  
  7. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  8. <%@page import="java.sql.*" %>
  9. <!DOCTYPE html>
  10. <html>
  11. <head>
  12. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  13. <title>JSP Page</title>
  14. </head>
  15. <body>
  16. <%
  17. String Bcode = request.getParameter("Bcode"); //product's ID
  18. String pname = request.getParameter("pname"); //product's name
  19. String price = request.getParameter("price"); //product's price
  20. String vat = request.getParameter("VAT"); //product's ΦΠΑ
  21. String desc = request.getParameter("desc"); //product's
  22.  
  23. Connection conn = null;
  24. Statement st = null;
  25.  
  26. try{
  27. Class.forName("com.mysql.jdbc.Driver");
  28. conn=(Connection)DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/dbproducts?autoReconnect=true&useSSL=false","prodadmin","78910");
  29. st=conn.createStatement();
  30.  
  31. String qry = "INSERT INTO products (prodcode, prodname, price, vat, description) VALUES( "+Bcode+", '"+pname+"', "+price+", "+vat+", '"+desc+"') " ;
  32.  
  33. st.executeUpdate(qry);
  34.  
  35. out.print("A new record inserted in Products Table.");
  36.  
  37.  
  38.  
  39. }catch( Exception ex ){
  40. out.print(ex.getMessage());
  41. }
  42.  
  43. %>
  44. </body>
Add Comment
Please, Sign In to add comment