Guest User

Untitled

a guest
Apr 19th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. if(name.trim().equals("")|| supp.trim().equals("")||range.trim().equals("")||size.equals("")||price.equals(""))
  2. z = "Please enter all fields";
  3. else
  4. {
  5. try
  6. {
  7. con = connectionclass(); // Connect to database
  8. if (con == null)
  9. {
  10. z = "Check Your Internet Access!";
  11. }
  12. else
  13. {
  14. String query = "BEGIN" +
  15. "IF NOT EXISTS(Select * from cc_lining)" +
  16. "BEGIN " +
  17. "INSERT INTO cc_lining (lining_id,lining_name, lining_range, lining_supplier, lining_width, lining_unit_price) VALUES ('"+id.toString()+"','"+ name.toString()+"','"+ range.toString()+"','"+ supp.toString()+"','"+size.toString()+"','"+price.toString()+"')" +
  18. "END" +
  19. "END";
  20. Statement stmt = con.createStatement();
  21. ResultSet rs = stmt.executeQuery(query);
  22. if(rs.next())
  23. {
  24.  
  25.  
  26.  
  27. isSuccess=true;
  28. con.close();
  29.  
  30.  
  31. }
  32. else
  33. {
  34. z = "Invalid!";
  35. isSuccess = false;
  36. }
  37. }
  38. }
  39. catch (Exception ex)
  40. {
  41. isSuccess = false;
  42. z = ex.getMessage();
  43. }
  44. }
  45. return z;
  46. }
  47. }
Add Comment
Please, Sign In to add comment