title: best way to call two database servers
body: <p>i want to call two table of different database at once.table of database A contains user id and table of database B contains user location with the user id, so i want to join these two tables and get the location corresponding to user_id.database A and B are in two different servers. so how can i join these two tables. if it is not possible to join this, is there any efficient way to do this.please help.i'm trying to do this using java, mysql.</p>
  
  <pre><code> ps = con.prepareStatement("SELECT user_id FROM A.users");
   rs = ps.executeQuery();
   while(rs.next())
      {
      //call select statement for database B to get the location for each user id             
  
      }
  </code></pre>
  
  <p>please suggest an efficient way to do this  </p>
  
  <pre><code>Id  User_id
  ===========
  1   44
  2   23
  
  User_id     location
  ====================
  44          india
  23          us
  </code></pre>