title: how can i retrieve data from multiple databases in a single query?
body: <p>if i have multiple database with same Tables and Columns how can i retrieve Data from those Databases using single Query in Java.
  Done this for single Database, i am newbie in java, please suggest.</p>
  
  <pre><code>public class MultipleDBTest{
     public void dbConnect(String db_connect_string, String db_userid, String db_password){
       try{
         Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
         Connection conn = DriverManager.getConnection(db_connect_string, db_userid, db_password);
         System.out.println("connected");
         Statement statement = conn.createStatement();
         String queryString = "select &lt;Col1&gt;, &lt;Col2&gt; from &lt;Table&gt;";
         ResultSet rs = statement.executeQuery(queryString);
          while(rs.next()){
            System.out.println(rs.getString(1) + " | " + rs.getString(2));
          }
        }
        catch(Exception e){
          e.printStackTrace();
        }
    }
  
    public static void main(String[] args){
      ConnectMSSQLServer connServer = new ConnectMSSQLServer();
      connServer.dbConnect("jdbc:sqlserver://localhost;databaseName=&lt;Database1&gt;","&lt;Username&gt;","&lt;Password&gt;");
    }
  }
  </code></pre>