Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%--
- Document : insert
- Created on : Jan 18, 2019, 2:40:38 PM
- Author : Jonathan
- --%>
- <%@page contentType="text/html" pageEncoding="UTF-8"%>
- <%@page import="java.sql.*" %>
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>JSP Page</title>
- </head>
- <body>
- <%
- String Bcode = request.getParameter("Bcode"); //product's ID
- String pname = request.getParameter("pname"); //product's name
- String price = request.getParameter("price"); //product's price
- String vat = request.getParameter("VAT"); //product's ΦΠΑ
- String desc = request.getParameter("desc"); //product's
- Connection conn = null;
- Statement st = null;
- try{
- Class.forName("com.mysql.jdbc.Driver");
- conn=(Connection)DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/dbproducts?autoReconnect=true&useSSL=false","prodadmin","78910");
- st=conn.createStatement();
- String qry = "INSERT INTO products (prodcode, prodname, price, vat, description) VALUES( "+Bcode+", '"+pname+"', "+price+", "+vat+", '"+desc+"') " ;
- st.executeUpdate(qry);
- out.print("A new record inserted in Products Table.");
- }catch( Exception ex ){
- out.print(ex.getMessage());
- }
- %>
- </body>
Add Comment
Please, Sign In to add comment