Note that there are some explanatory texts on larger screens.

plurals
  1. POJava problems in query
    primarykey
    data
    text
    <p>Here is my code:</p> <pre><code>String data[]=new String[10]; String[] result; Product p= new Product(); int serial=0; try{ String sql="select * from product"; rslt=st.executeQuery(sql); while(rslt.next()){ data[1]=rslt.getString("p_code"); data[2]=rslt.getString("catagory"); data[3]=rslt.getString("p_name"); data[4]=rslt.getString("description"); data[5]=rslt.getString("measurement"); //data[6]=Integer.toString(p.RemainProduct(data[1])); //Stock //data[7]=p.getSellPrice(data[1]); //sell price serial+=1; data[0]=Integer.toString(serial); DTB.addRow(data); } }catch(Exception ex){ System.out.println("ERROR :"+ex); } </code></pre> <p>the above code shows me all the product from database as desired here is the result <img src="https://i.stack.imgur.com/6Kou5.png" alt="enter image description here"></p> <p>but when i uncomment <code>data[6]</code> and <code>data[7]</code> then it shows me only one product information from database.here is my result <img src="https://i.stack.imgur.com/EMuvu.png" alt="enter image description here"> My <code>RemainProduct(data[1])</code> and <code>getSellPrice(data[1])</code> method is working fine because it is giving the actual stock and sell price for the product.My problem is why i am getting only one result when i uncomment those two line.someone please fix this problem.</p> <p>here is my getSellPrice method </p> <pre><code> public String getSellPrice(String pCode){ String[] data; String[] price= new String[2]; data=productDB.getProductPrice(pCode); int i=0; for(String s:data){ price[i]=s; i +=1; } String sell=price[1]; return sell; } </code></pre> <p>and here is my remainproduct method</p> <pre><code> public int RemainProduct(String pCode){ if(oc.isOrdered(pCode)){ int remain=Integer.parseInt(ProductTotalStock(pCode))-Integer.parseInt(prouductTotalSold(pCode))-getProductOrdered(pCode); return remain; }else{ int remain=Integer.parseInt(ProductTotalStock(pCode))-Integer.parseInt(prouductTotalSold(pCode)); return remain; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload