public class ProductServices { public boolean addProduct(ProductBean bean,Connection con)throws SQLException { PreparedStatement st=null; try { String productName=bean.getProductName(); String desc=bean.getDescription(); String features=bean.getFeatures(); String price=bean.getPrice(); String quantity=bean.getQuantity(); String eligibility=bean.getEligibility(); String thresholdLimit=bean.getThresholdLimit(); String colorCode="green"; st=con.prepareStatement("insert into product values(seq_person.nextval,'"+productName+"','"+price+"','"+quantity+"','"+thresholdLimit+"','"+features+"','"+desc+"','"+eligibility+"','"+colorCode+"')"); int rs=st.executeUpdate(); } catch(Exception e) { e.printStackTrace(); } finally { con.close(); st.close(); } return false; } public void updateProduct(ProductBean bean, Connection conn) throws SQLException { PreparedStatement statement=null; try { String productname = bean.getProductName(); String price = bean.getPrice(); String quantity = bean.getQuantity(); String thresholdLimit=bean.getThresholdLimit(); String eligibility=bean.getEligibility(); statement = conn.prepareStatement("Update Product set PRICE='"+price+"',QUANTITY='"+quantity+"',THRESHOLD_LIMIT='"+thresholdLimit+"',ELIGIBILITY_FOR_REWARDS='"+eligibility+"' where PROD_MODEL_NAME='"+productname+"' "); int rs=statement.executeUpdate(); } catch (SQLException sqle) { conn.close(); } catch (Exception e) { conn.close(); } finally { conn.close(); statement.close(); } } public void deleteProduct(ProductBean bean, Connection conn) throws SQLException { PreparedStatement statement=null; try { String productName = bean.getProductName(); String price = bean.getPrice(); String quantity = bean.getQuantity(); String thresholdLimit=bean.getThresholdLimit(); String eligibility=bean.getEligibility(); statement = conn.prepareStatement("Delete Product where PROD_MODEL_NAME='"+productName+"' "); int rs=statement.executeUpdate(); statement = conn.prepareStatement("Delete ret_prod where PRODUCT_ID in(select PRODUCT_ID from Product where PROD_MODEL_NAME='"+productName+"' )"); int rs1=statement.executeUpdate(); statement = conn.prepareStatement("Delete stock where PRODUCT_ID in(select PRODUCT_ID from Product where PROD_MODEL_NAME='"+productName+"' ) "); int rs2=statement.executeUpdate(); } catch (SQLException sqle) { } catch (Exception e) { } finally { conn.close(); statement.close(); } }
Ads