Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. public static void main(String args[])
  2. {
  3. int count = 0;
  4. boolean status = false;
  5. //count = retrieveData(); Current code working but captures only 1 values at a time i.e. Count not the status
  6.  
  7. /* Expected Code
  8.  
  9. if (status == true) // where status and count is returned from retrieveData method
  10. {
  11. count = retrieveData();
  12. System.out.println("Status is true so can proceed");
  13. }
  14.  
  15. else
  16. System.out.println("Status is not true so don't proceed");
  17. */
  18. }
  19.  
  20.  
  21.  
  22.  
  23.  
  24. public static int retrieveData() throws Exception
  25. {
  26.  
  27. boolean success = false;
  28. String query = "SELECT Count(1) FROM Account";
  29. int totalCount=0;
  30. ResultSet rsRetrieve = null;
  31. Statement stmt = null;
  32. stmt = conn.createStatement();
  33. rsRetrieve = stmt.executeQuery(query);
  34. while (rsRetrieve.next())
  35. {
  36. totalCount= rsRetrieve.getInt(1);
  37. System.out.println("totalCount : "+totalCount);
  38. }
  39.  
  40.  
  41. success = true;
  42. return totalCount; // current working code but returns only 1 value i.e. Count not status
  43.  
  44. /* Expected
  45.  
  46. return success + totalCount
  47.  
  48. */
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement