Advertisement
Guest User

Untitled

a guest
Mar 30th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. public class BankDatabaseSQL {
  2. private Connection connection;
  3. private ResultSet resultSet;
  4.  
  5. private static final String URL = "jdbc:mysql://localhost/banktesting";
  6. private static final String USERNAME = "root";
  7.  
  8. Account account;
  9.  
  10. public final Object monitor = new Object();
  11.  
  12. private PreparedStatement setBalance;
  13. private PreparedStatement getAccount;
  14. int numberOfRows;
  15.  
  16. /** code omitted **/
  17.  
  18. /**
  19. method in question
  20. */
  21. public synchronized boolean authenticatePrint(){
  22.  
  23. try{
  24. MainForm mainForm = new MainForm();
  25. do{
  26. ExecutorService threadExecutor = Executors.newCachedThreadPool();
  27. mainForm.accNo = account.getAccountNumber();
  28. threadExecutor.execute(mainForm);
  29. wait();
  30. }while(mainForm.verified = false); // while the verified variable of the mainForm object is set to false,
  31. // the thread should keep waiting. The process has not gotten into this
  32. // if statement.
  33. if(mainForm.verified = true){
  34.  
  35. System.out.println("time to notify");
  36. notify();
  37. }
  38.  
  39. public class MainForm extends JFrame implements Runnable
  40. {
  41. public void run() {
  42. new MainForm();
  43.  
  44. }
  45. public synchronized void onVerify() {
  46. VerificationForm form = new VerificationForm(this);
  47. form.setVisible(true);
  48. System.out.println("nTime to onVerify");
  49. if(form.verificationStatus = true){
  50. verified = true; // variable for the mainForm object to aid in notifying the thread
  51. System.out.println("nVerified = true has been set!");
  52.  
  53. }
  54.  
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement