[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.2

i have an error in insert to database

Asked by LunarStar76 in Java Server Pages (JSP)

Tags: database, insert

this is my product screen i suppose to add product into the database db2 but when i insert to database it give me error (null for supplier id) please help me
this is my screen.
<%@ page contentType="text/html; charset=" language="java" import="java.sql.*" errorPage="" %>
<html>
<head>
<title>AddProduct</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form name="form1" method="post" action="http://localhost:8080/Inventory/ap">
  <table width="100%" border="0">
    <tr>
      <td height="77" colspan="4"> <div align="center"><font size="6" face="Verdana, Arial, Helvetica, sans-serif"><strong>Product</strong></font></div></td>
    </tr>
    <tr>
      <td width="18%">&nbsp;</td>
      <td width="31%">&nbsp;</td>
      <td width="12%"><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"></font></div></td>
      <td width="39%">&nbsp;</td>
    </tr>
    <tr>
      <td> <div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
          <label>Product ID &nbsp;</label>
          </font></div></td>
      <td> <input name="prodID_f" size="20"></td>
      <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
          <label>Category</label>
          &nbsp;</font></div></td>
             
      <td><select name="select">
        </select> </td>
    </tr>
    <tr>
      <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
          <label>Barcode &nbsp;</label>
          </font></div></td>
      <td><input name="prodCode_f" size="20"></td>       
     
      <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
          <label>Qty On Hand&nbsp;</label>
          </font></div></td>
      <td><input name="prodQty_f" size="20"></td>
    </tr>
    <tr>
      <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
          <label>Desc &nbsp;</label>
          </font></div></td>
      <td><input name="prodDesc_f" size="30"></td>
      <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
          <label>Order Level &nbsp;</label>
          </font></div></td>
      <td><input name="prodLevel_f" size="20"></td>
    </tr>
    <tr>
      <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
          <label>Price &nbsp;</label>
          </font></div></td>
      <td><input name="prodPrice_f" size="20"></td>
      <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
          <label>Supplier &nbsp;</label>
          </font></div></td>
      <td><select name="supp_f">
        </select></td>
    </tr>
    <tr>
      <td><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
          <label>GST &nbsp;</label>
          </font></div></td>
      <td><input name="prodGST_f" size="20"></td>
      <td> <div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
          <label>Dept &nbsp;</label>
          </font></div></td>
      <td><select name="select2">
        </select></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;<input type="submit" name="prodSubmit" value=" Add "></td>
      <td>&nbsp;</td>
      <td><div align="right"></div></td>
    </tr>
  </table>

</form>
</body>
</html>
this is my product entity
package inventory.inv_Bean;

public class Product_entity
{

 private int prodID;
 private int barcode;
 private String desc;
 private double regPrice;
 private double gst;
 private double qoh;
 private int orderLevel;
 private int orderQuantity;

 public Product_entity(int prodID,int barcode, String desc, int orderQuantity)
 {
       this.prodID= prodID;
       this.barcode = barcode;
       this.desc = desc;
       this.orderQuantity = orderQuantity;
 }


  public Product_entity(int prodID, int barcode, String desc, double regPrice, double gst,
                                      double qoh, int orderLevel, int orderQuantity)
  {
    setProdID(prodID);
    setBarcode(barcode);
    setDesc(desc);
    setRegPrice(regPrice);
    setGst(gst);
    setQoh(qoh);
    setOrderLevel(orderLevel);
    setOrderQuantity(orderQuantity);
 }




 public void setProdID(int prodID) {
   this.prodID= prodID;
 }
 public int getProdID() {
   return prodID;
 }

 public void setBarcode(int barcode) {
   this.barcode = barcode;
 }
 public int getBarcode() {
   return barcode;
 }

 public void setDesc(String desc) {
   this.desc = desc;
 }
 public String getDesc() {
   return desc;
 }

  public void setRegPrice(double regPrice) {
    this.regPrice = regPrice;
 }
 public double getRegPrice() {
   return regPrice;
 }

 public void setGst(double gst) {
   this.gst = gst;
 }
  public double getGst() {
    return gst;
 }

 public void setQoh(double qoh) {
   this.qoh = qoh;
 }
 public double getQoh() {
   return qoh;
 }

 public void setOrderLevel(int orderLevel) {
   this.orderLevel = orderLevel;
 }
 public int getOrderLevel() {
   return orderLevel;
 }

 public void setOrderQuantity(int orderQuantity){
       this.orderQuantity = orderQuantity;
 }

 public int getOrderQuantity(){
       return orderQuantity;
 }

}
 this is my servlet
package inventory.servlet;

// AddProductServlet.java
// Servlet for adding product to the database. Web-based database access.


import java.io.*;
import javax.servlet.*;

import javax.servlet.http.*;
import java.util.*;
import java.sql.*;
import inventory.inv_Bean.*;

public class AddProServlet extends HttpServlet
{


  private static final String CONTENT_TYPE = "text/html";

    //boolean success;

    PrintWriter output;

    Inv_DBQuery db;
    Product_entity product;

    public void init() throws ServletException
    {

    }

    public void doGet(HttpServletRequest req, HttpServletResponse res)throws ServletException, IOException
    {
        doPost(req, res);
    }

    public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
    {
        output = res.getWriter();

            int id = Integer.parseInt(req.getParameter("prodID_f"));
            int code = Integer.parseInt(req.getParameter("prodCode_f"));
      String desc = req.getParameter("prodDesc_f");
              double regPrice =Double.parseDouble( req.getParameter("prodPrice_f"));
              double gst =Double.parseDouble(req.getParameter("prodGST_f"));
              double qtyHand = Double.parseDouble(req.getParameter("prodQty_f"));
      int level = Integer.parseInt(req.getParameter("prodLevel_f"));
      int orderQty = Integer.parseInt(req.getParameter(""));

              res.setContentType("text/html");
          //      System.out.println("OK1");

     /*           if (desc.equals(""))

                {

                        res.setContentType(CONTENT_TYPE);
                        output.println("<h3>Please click the back button and fill in" +
                                 " all required fields.</h3>");
            output.close();
        }
        else
        { */

         product = new Product_entity(id, code, desc, regPrice, gst, qtyHand, level, orderQty);

             db = new Inv_DBQuery();

             db.addProduct(product);

              System.out.println("product OK");

         output.close();

       }

    }





[+][-]05/27/04 12:55 AM, ID: 11169212Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Java Server Pages (JSP)
Tags: database, insert
Sign Up Now!
Solution Provided By: vikram_1982
Participating Experts: 3
Solution Grade: A
 
[+][-]05/27/04 02:37 AM, ID: 11169697Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05/27/04 08:19 AM, ID: 11172563Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05/28/04 10:04 AM, ID: 11182249Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07/24/04 08:31 AM, ID: 11628437Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]07/28/04 05:50 AM, ID: 11655760Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091118-EE-VQP-93