title: How would I join and insert data to the VO from 2 different database
body: <p>Before I only have 1 SQL query where all of the column fields located in only 1 database. But now I need to move the StudentAccess to a different database. I need to join both of the database record and insert it to my VO object.</p>
  <p>Database 1:
  Select STUD_ID_NR, STUD_NM, STUD_LOG_ID
  from Student</p>
  <p>Database 2:
  SELECT STUD_LOG_ID, STUD_LOG_ID from StudentAccess
  WHERE logFlag= true</p>
  <p>The STUD_LOG_ID will be the identifier for both of the table to join them.</p>
  <p>This is my current code before that store data from only 1 Database</p>
  <p>Class 1:</p>
  <pre><code>try
  {
      conn = getDataSource().getConnection();
      stmt = conn.createStatement()
      rs = stmt.executeQuery(StudentQuery);
      
  
      List&lt;StudentVO&gt; listOfStudents = new ArrayList&lt;StudentVO&gt;;
      
      if(null != rs)
       {
        while(rsv.next())
         {
           StudentVO validStudent = StudentsMapper.mapToVo(rs.getString(STUD_ID_NR), 
           rs.getString(STUD_NM), rs.getString(STUD_LOG_ID));
  
           if(validStudents != null)
            {
              listOfStudents.add(validstudent);
            }
        
      StudentStore.setAllStudents(listOfStudents);
  }
  </code></pre>
  <p>If the data's are coming from two database. how would I Still insert the STUD_LOG_IN_ID of the student to the VO if their STUD_LOG_ID had a match?</p>
  <p>Let's assume that we can call both of the database in this class.</p>
  <pre><code>try
  {
      conn = getDataSource().getConnection();
      stmt = conn.createStatement()
      rs = stmt.executeQuery(StudentQuery);
      rs2 = stmt.executeQuery(StudentAccessQuery);
  
      List&lt;StudentVO&gt; listOfStudents = new ArrayList&lt;StudentVO&gt;;
      
              if(null != rs2)
               {
                while(rsv.next())
                 {
                 }
               }
      
              if(null != rs)
               {
                while(rsv.next())
                 {
                 }
          
              StudentStore.setAllStudents(listOfStudents);
      }
  </code></pre>
  <p>I'm quite confused on how will I do it. should I add both record in an arraylist first then use the contain?</p>
  <p>My VO contains the STUD_ID_NR,STUD_NM,STUD_LOG_IN_ID</p>