Guest User

Untitled

a guest
Aug 9th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. public class App {
  2.  
  3. private App(MysqlDB database) {
  4. this.database = database;
  5. }
  6.  
  7. public final MysqlDB database;
  8. ExecutorService executor = Executors.newFixedThreadPool(5);
  9.  
  10. BlockingQueue<String> taskQueue = new LinkedBlockingQueue<String>();
  11.  
  12. static String username ="abc123"
  13.  
  14. public static void main(String[] args) throws SQLException, Exception {
  15.  
  16. Connection conn = DriverManager.getConnection(
  17. "jdbc:mysql://localhost/db",
  18. "user",
  19. "pass:35"
  20. );
  21.  
  22. try {
  23. MysqlDB database = new MysqlDB(conn);
  24. // do some stuff here, start threads, etc.
  25. }
  26. catch(Exception e){
  27. System.out.println(e);
  28. }
  29. }
  30.  
  31. ----------------------------------------------------------
  32. class workerThread implements Runnable{
  33.  
  34. public void run() {
  35. System.out.println(username); // 'cannot resolve symbol'
  36.  
  37. String query = 'select * from foobar";
  38. database.doQuery(query); // doQuery is defined in a separate class file. It WORKS in the main App, but fails here with 'cannot resolve symbol"
  39. }
  40. }
Add Comment
Please, Sign In to add comment