Search code examples
javasqlresultset

Get java ResultSet from multiple connections in one query


I need to write a JAVA code to retrieve data as a ResultSet from multiple connections by using one SQL statement.

For example:

SELECT *
FROM       CONNECTION1.DB1.TABLE1 T1
INNER JOIN CONNECTION2.DB2.TABLE2 T2 ON T1.FIELD1 = T2.FIELD2

Is it possible? and how?

Thanks!


Solution

  • It may possible to configure in database level, i thik that no way to do this with two JDBC connections. For example in MySQL you can set up federated tables:

    The FEDERATED Storage Engine | FEDERATED Storage Engine Notes and Tips