GeeCON Prague 2014*
The moose likes JDBC and the fly likes Fetch data from different database schema tables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "Fetch data from different database schema tables" Watch "Fetch data from different database schema tables" New topic
Author

Fetch data from different database schema tables

suresh pilakal babu
Ranch Hand

Joined: Jul 01, 2008
Posts: 31
Hello

I want to execute a query, which contains tables from different database schema.
How can i create a single connection object for different schemas.I am using oracle database.
Is it possible?


Thanks,
Suresh.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

A single statament? So presumably you are just unioning unrelated entities?

There is nothing in JDBC that will let you do this. However, an Oracle only workaround would be to use a global link (see the Oracle documentation) to access one database from another. I think once you have this you can write SQL like:

and you'll get what you want.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Paul Campbell
Ranch Hand

Joined: Oct 06, 2007
Posts: 338
Originally posted by Paul Sturrock:
A single statament? So presumably you are just unioning unrelated entities?

There is nothing in JDBC that will let you do this. However, an Oracle only workaround would be to use a global link (see the Oracle documentation) to access one database from another. I think once you have this you can write SQL like:

and you'll get what you want.


You can also do the following in Oracle without the global link:



The caveat to this is: your user name and password must be identical for dbname1 and dbname2
[ December 16, 2008: Message edited by: Paul Campbell ]
 
GeeCON Prague 2014
 
subject: Fetch data from different database schema tables