JDBC - Connecting Multiple Databases
Hi JDBC's
I would like to know if it is possible to retrive a data from different tables and from different databases using a single query, which mean can I retrive data from multiple tables multiple databases in a single JDBC connection?
If not, How do I implement it?
Any Ideas or please point me to any related solution if you have.
Thanks.
[377 byte] By [
awd1999a] at [2007-11-26 21:24:25]

# 2
Although theoretically possible in fact a single JDBC connection cannot work with several databases. To implement this feature somebody has to write another aggregating JDBC driver which parse SQL statement and work with other databases in background. I like this idea, but currently there is no such driver available.
Scriptella ETL (http://scriptella.javaforge.com) offers an interesting solutions for cross-database operations. See example on how -to copy a table from oracle to hsqldb: http://snippets.dzone.com/posts/show/3511
If you want to join 2 tables from different databases and copy the result to a third database use the following code:
<query connection-id="db1">
SELECT * FROM Table1
<query connection-id="db2">
SELECT * FROM Table2 WHERE Table2_ID=?Table1_ID
<script connection-id="db3">
INSERT INTO Table3 VALUES (?rownum, ?Table1_Field, ?Table2_Field);
</script>
</query>
</query>
Message was edited by:
ejboy